source: Dev/trunk/RGraph/examples/text.html @ 77

Last change on this file since 77 was 77, checked in by fpvanagthoven, 14 years ago

RGraph

File size: 5.2 KB
RevLine 
[77]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: Javascript charts &amp; HTML5 canvas charts 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
57    <script>
58      var _gaq = _gaq || [];
59      _gaq.push(['_setAccount', 'UA-54706-2']);
60      _gaq.push(['_trackPageview']);
61   
62      (function() {
63        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
64        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
65        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
66      })();
67    </script>
68</head>
69<body>
70
71<div id="breadcrumb">
72    <a href="../index.html">RGraph: Javascript charts &amp; HTML5 canvas charts library</a>
73    >
74    <a href="./index.html">Examples</a>
75    >
76    Rotating text
77</div>
78
79<h1>RGraph: Javascript charts &amp; HTML5 canvas charts - A text function that does horizontal and vertical alignment (and spins)</h1>
80
81
82
83<table border="0" style="float: left; margin-right: 10px">
84    <tr>
85        <td colspan="2"><canvas id="myc" width="300" height="300" style="border: 1px dashed gray">The fallback HTML</canvas></td>
86    </tr>
87
88    <tr>
89        <td align="center">
90            <button style="width: 100px; margin: 5px" onclick="__RGraph_rotate2 -= 5">&laquo; Rotate left</button>&nbsp;
91            <button style="margin: 5px" onclick="if (this.innerHTML == 'Pause') {__pause = true; this.innerHTML = 'Play'} else {this.innerHTML = 'Pause'; __pause = false; }">Pause</button>&nbsp;
92            <button style="width: 100px; margin: 5px" onclick="__RGraph_rotate2 += 5">Rotate right&raquo;</button>
93        </td>
94    </tr>
95</table>
96
97<p>
98    RGraph.Text() is a text drawing function that allows vertical and horizontal alignment, and allows you to specify the angle of the
99    text too. The animation is done by a simple gobal variable, setTimeout() and redrawing the entire
100    canvas every frame. Perhaps not the most efficient of methods, but remember that your Javascript will likely be
101    running on computers that have more processing power than
102    some small countries... <a href="javascript: location.href = location.href">Reset the page</a>
103</p>
104
105<p>
106    In a similar vein you could easily make some text that bounces from one side of the screen to the other,
107    hurrah - the return of &lt;marquee&gt;!
108</p>
109
110    <div>
111        More examples can be found on the individual <a href="/examples/index.html">example pages</a>, and a more complete
112        reference to the Text() function can be found in the <a href="../docs/api.html#functions.other">API docs</a>.
113    </div>
114
115</body>
116</html>
Note: See TracBrowser for help on using the repository browser.