1 <?php ob_start('ob_gzhandler') ?>
5 <meta http-equiv="X-UA-Compatible" content="chrome=1">
8 * o------------------------------------------------------------------------------o
9 * | This file is part of the RGraph package - you can learn more at: |
11 * | http://www.rgraph.net |
13 * | This package is licensed under the RGraph license. For all kinds of business |
14 * | purposes there is a small one-time licensing fee to pay and for non |
15 * | commercial purposes it is free to use. You can read the full license here: |
17 * | http://www.rgraph.net/LICENSE.txt |
18 * o------------------------------------------------------------------------------o
21 <title>RGraph: HTML5 canvas graph library - Animated rotating text with the RGraph software</title>
23 <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
24 <link rel="icon" type="image/png" href="../images/favicon.png">
26 <script src="../libraries/RGraph.common.core.js" ></script>
29 __pause = false; // Provide a way to pause the rotation
30 __RGraph_rotate = 0; // A record of the angle (IN DEGREES) we're at currently
31 __RGraph_rotate2 = 0; // Ditto, but this is controlled by the buttons
33 window.onload = function ()
37 var canvas = document.getElementById("myc");
38 var context = canvas.getContext('2d');
40 RGraph.Clear(canvas); // Clears the canvas
43 context.fillStyle = 'black';
45 RGraph.Text(context, 'Verdana',10,canvas.width/2,canvas.height/2,'Magic text! (' + __RGraph_rotate + ')','center','center',false, ++__RGraph_rotate);
46 RGraph.Text(context, 'Verdana', 16, 50, 50, 'This is making me dizzy... (' + (__RGraph_rotate * 5) + ')', 'center', 'left', false, __RGraph_rotate * 2);
47 RGraph.Text(context, 'Verdana', 20, 50, 200, 'Some user controllable text (' + __RGraph_rotate2 + ')', 'center', 'center', false, __RGraph_rotate2);
53 setTimeout(window.onload, 1);
60 <a href="../index.html">RGraph: HTML5 canvas graph library</a>
62 <a href="./index.html">Examples</a>
67 <h1>RGraph: A text function that does horizontal and vertical alignment (and spins)</h1>
71 <table border="0" style="float: left; margin-right: 10px">
73 <td colspan="2"><canvas id="myc" width="300" height="300" style="border: 1px dashed gray">The fallback HTML</canvas></td>
78 <button style="width: 100px; margin: 5px" onclick="__RGraph_rotate2 -= 5">« Rotate left</button>
79 <button style="margin: 5px" onclick="if (this.innerHTML == 'Pause') {__pause = true; this.innerHTML = 'Play'} else {this.innerHTML = 'Pause'; __pause = false; }">Pause</button>
80 <button style="width: 100px; margin: 5px" onclick="__RGraph_rotate2 += 5">Rotate right»</button>
86 RGraph.Text() is a text drawing function that allows vertical and horizontal alignment, and allows you to specify the angle of the
87 text too. The animation is done by a simple gobal variable, setTimeout() and redrawing the entire
88 canvas every frame. Perhaps not the most efficient of methods, but remember that your Javascript will likely be
89 running on computers that have more processing power than
90 some small countries... <a href="javascript: location.href = location.href">Reset the page</a>
94 In a similar vein you could easily make some text that bounces from one side of the screen to the other,
95 hurrah - the return of <marquee>!
99 More examples can be found on the individual <a href="/examples/index.html">example pages</a>, and a more complete
100 reference to the Text() function can be found in the <a href="../docs/api.html#functions.other">API docs</a>.