forked from enterprisebug/grid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
179 lines (147 loc) · 6.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Grid.js by enterprisebug</title>
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<link rel="stylesheet" type="text/css" href="assets/fd-slider/fd-slider.css?v=2">
<link rel="stylesheet" type="text/css" href="assets/fd-slider/fd-slider-tooltip.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="assets/fd-slider/fd-slider.js"></script>
<script type="text/javascript" src="assets/jscolor/jscolor.js"></script>
<script type="text/javascript" src="dist/grid.js"></script>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/enterprisebug/grid.js">View on GitHub</a>
<h1 id="project_title">Grid.js</h1>
<h2 id="project_tagline">Will draw a nice grid on a HTML5 canvas element</h2>
<section id="downloads">
<a class="zip_download_link" href="https://github.com/enterprisebug/grid.js/blob/gh-pages/dist/grid.min.js">grid.min.js</a>
<a class="tar_download_link" href="https://github.com/enterprisebug/grid.js/blob/gh-pages/dist/grid.js">grid.js</a>
</section>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h2>Demo / Configuration</h2>
<div id="demo_left">
<canvas id="myCanvas" width="350" height="200"></canvas>
</div>
<div id="demo_right">
<form id="opts">
<label>Distance:</label><input type="text" name="distance" min="5" max="100" step="1" value="30" /><br />
<label>LineWidth:</label><input type="text" name="lineWidth" min="0" max="5" step="0.1" value="1" /><br />
<label>Caption:</label><input type="checkbox" name="caption" /><br/>
<label>GridColor:</label><input class="color" value="#66ff00" color="#66ff00" name="gridColor" />
</form>
</div>
<div style="clear:both;"></div>
<h2>Usage</h2>
<p>Assume that we have a HTML5 canvas element:</p>
<div class="highlight"><pre><span class="nt"><canvas</span> <span class="na">id=</span><span class="s">"myCanvas"</span> <span class="na">width=</span><span class="s">"350"</span> <span class="na">height=</span><span class="s">"200"</span><span class="nt">></canvas></span></pre></div>
<p>Use grid like this:</p>
<div class="highlight">
<pre>
<span class="kd">var</span> <span class="nx">canvas</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">"myCanvas"</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">context</span> <span class="o">=</span> <span class="nx">canvas</span><span class="p">.</span><span class="nx">getContext</span><span class="p">(</span><span class="s2">"2d"</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">opts</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">distance</span> <span class="o">:</span> <span class="mi"><span id="opt-distance">20</span></span><span class="p">,</span>
<span class="nx">lineWidth</span> <span class="o">:</span> <span class="mf"><span id="opt-lineWidth">1.5</span></span><span class="p">,</span>
<span class="nx">gridColor </span> <span class="o">:</span> <span class="s2">"<span id="opt-gridColor">#ff0000</span>"</span><span class="p">,</span>
<span class="nx">caption</span> <span class="o">:</span> <span class="kc"><span id="opt-caption">true</span></span>
<span class="p">};</span>
<span class="k">new</span> <span class="nx">Grid</span><span class="p">(</span><span class="nx">opts</span><span class="p">).</span><span class="nx">draw</span><span class="p">(</span><span class="nx">context</span><span class="p">);</span>
</pre>
</div>
<script>
$(function() {
var params = {};
var hash = /^#\?(.*)/.exec(location.hash);
if (hash) {
$.each(hash[1].split(/&/), function(i, pair) {
var kv = pair.split(/=/);
params[kv[0]] = kv[kv.length-1];
});
}
$('#opts input[min]').each(function() {
var val = params[this.name];
if (val !== undefined) this.value = val;
this.onchange = animate;
});
$('#opts input[color]').each(function() {
var val = params[this.name];
if (val !== undefined) this.value = val;
this.onchange = animate;
});
$('#opts input:checkbox').each(function() {
this.checked = !!params[this.name];
this.onclick = animate;
});
animate();
});
function animate() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
// clear stage
context.clearRect(0, 0, canvas.width, canvas.height);
var opts = {};
$('#opts input[min]').each(function() {
$('#opt-' + this.name).text(opts[this.name] = parseFloat(this.value));
});
$('#opts input[color]').each(function() {
$('#opt-' + this.name).text(opts[this.name] = this.value);
});
$('#opts input:checkbox').each(function() {
opts[this.name] = this.checked;
$('#opt-' + this.name).text(this.checked);
});
new Grid(opts).draw(context);
}
</script>
<h2>Support or Contact</h2>
<p>
<img src="https://pbs.twimg.com/profile_images/745199995/daniel_profile_bigger.jpg" alt="Daniel Sirz" valign="top" align="left" id="twitter_image"/>
If you encounter any problems, please use the <a href="https://github.com/enterprisebug/grid.js/issues">GitHub issue tracker</a>.<br />
For updates <a href="http://twitter.com/danielsirz">follow me on Twitter</a>.<br />
If you like <a href="https://github.com/enterprisebug/grid.js">grid.js</a>, let me know.<br /><br />
</p>
<h2>Changes</h2>
<h3>Version 1.1 (2012-08-20)</h3>
<ul>
<li>Added Caption</li>
<li>Added gridColor</li>
</ul>
<h3>Version 1.0 (2012-08-14)</h3>
<ul>
<li>Initial Realease</li>
</ul>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p class="copyright">Grid.js maintained by <a href="https://github.com/enterprisebug">enterprisebug</a></p>
<p>Published with <a href="http://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-34207705-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>