initial commit
[home-automation.git] / RGraph / examples / text.html
1 <?php ob_start('ob_gzhandler') ?>
2 <!DOCTYPE html>
3 <html>
4 <head>
5     <meta http-equiv="X-UA-Compatible" content="chrome=1">
6     <!--
7         /**
8         * o------------------------------------------------------------------------------o
9         * | This file is part of the RGraph package - you can learn more at:             |
10         * |                                                                              |
11         * |                          http://www.rgraph.net                               |
12         * |                                                                              |
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:  |
16         * |                                                                              |
17         * |                      http://www.rgraph.net/LICENSE.txt                       |
18         * o------------------------------------------------------------------------------o
19         */
20     -->
21     <title>RGraph: HTML5 canvas graph library - Animated rotating text with the RGraph software</title>
22
23     <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
24     <link rel="icon" type="image/png" href="../images/favicon.png">
25
26     <script src="../libraries/RGraph.common.core.js" ></script>
27     
28     <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
32
33         window.onload = function ()
34         {
35             
36             if (!__pause) {
37                 var canvas  = document.getElementById("myc");
38                 var context = canvas.getContext('2d');
39
40                 RGraph.Clear(canvas); // Clears the canvas
41     
42                 context.beginPath();
43                     context.fillStyle = 'black';
44
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);
48     
49                 context.stroke();
50                 context.fill();
51             }
52             
53             setTimeout(window.onload, 1);
54         }
55     </script>
56 </head>
57 <body>
58
59 <div id="breadcrumb">
60     <a href="../index.html">RGraph: HTML5 canvas graph library</a>
61     >
62     <a href="./index.html">Examples</a>
63     >
64     Rotating text
65 </div>
66
67 <h1>RGraph: A text function that does horizontal and vertical alignment (and spins)</h1>
68
69
70
71 <table border="0" style="float: left; margin-right: 10px">
72     <tr>
73         <td colspan="2"><canvas id="myc" width="300" height="300" style="border: 1px dashed gray">The fallback HTML</canvas></td>
74     </tr>
75
76     <tr>
77         <td align="center">
78             <button style="width: 100px; margin: 5px" onclick="__RGraph_rotate2 -= 5">&laquo; Rotate left</button>&nbsp;
79             <button style="margin: 5px" onclick="if (this.innerHTML == 'Pause') {__pause = true; this.innerHTML = 'Play'} else {this.innerHTML = 'Pause'; __pause = false; }">Pause</button>&nbsp;
80             <button style="width: 100px; margin: 5px" onclick="__RGraph_rotate2 += 5">Rotate right&raquo;</button>
81         </td>
82     </tr>
83 </table>
84
85 <p>
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>
91 </p>
92
93 <p>
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 &lt;marquee&gt;!
96 </p>
97
98     <div>
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>.
101     </div>
102
103 </body>
104 </html>