forked from tsand/responsive-sketchpad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
176 lines (148 loc) · 5.68 KB
/
Copy pathindex.html
File metadata and controls
176 lines (148 loc) · 5.68 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Responsive Sketchpad</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="assets/normalize.css">
<link rel="stylesheet" href="assets/skeleton.css">
<link rel="stylesheet" href="assets/custom.css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="images/favicon.png">
<!-- Google Analytics
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-33670860-4', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div class="container">
<section class="text-center">
<h2>Sez-AI Sketchpad</h2>
<h5>A completely responsive, HTML5 canvas sketchpad for use on desktop and mobile browsers</h5>
</section>
<section>
<div id="sketchpad"></div>
<em>Try resizing the window!</em>
<button class="u-full-width" style="color:green" id="process">Process</button>
</section>
<!--
<section>
<div class="row">
<div class="two-thirds column">
<div id="sketchpad"></div>
<em>Try resizing the window!</em>
</div>
<div class="one-third column">
<label for="line-color-input">Set Line Color</label>
<input class="u-full-width" type="text" value="#000000" id="line-color-input">
<label for="line-size-input">Set Line Size</label>
<input class="u-full-width" type="number" value="5" id="line-size-input">
<div class="row">
<div class="one-half column">
<button class="u-full-width" id="undo">Undo</button>
</div>
<div class="one-half column">
<button class="u-full-width" id="redo">Redo</button>
</div>
<button class="u-full-width" id="clear">Clear</button>
</div>
</div>
</div>
</section>
<section>
<h3>Basic Usage</h3>
<pre><code>var Sketchpad = require('responsive-sketchpad');
// Initialize Sketchpad
var el = document.getElementById('sketchpad');
var pad = new Sketchpad(el, {
line: {
color: '#f44335',
size: 5
}
});
// Set line color
pad.setLineColor('#f44336');
// Set line size
pad.setLineSize(10);
// Undo
pad.undo();
// Redo
pad.redo();
// Clear canvas
pad.clear();
// Resize canvase
pad.resize(newWidth);
</code></pre>
</section>
-->
</div>
<!-- Scripts
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<script src="responsive-sketchpad.js"></script>
<script>
var el = document.getElementById('sketchpad');
var pad = new Sketchpad(el, {aspectRatio: 0.25, line: {size: 2}});
// // setLineColor
// function setLineColor(e) {
// var color = e.target.value;
// if (!color.startsWith('#')) {
// color = '#' + color;
// }
// pad.setLineColor(color);
// }
// document.getElementById('line-color-input').oninput = setLineColor;
// // setLineSize
// function setLineSize(e) {
// var size = e.target.value;
// pad.setLineSize(size);
// }
// document.getElementById('line-size-input').oninput = setLineSize;
// // undo
// function undo() {
// pad.undo();
// }
// document.getElementById('undo').onclick = undo;
// // redo
// function redo() {
// pad.redo();
// }
// document.getElementById('redo').onclick = redo;
// // clear
// function clear() {
// pad.clear();
// }
// document.getElementById('clear').onclick = clear;
// process
function process() {
console.log(pad.toJSON());
}
document.getElementById('process').onclick = process;
// resize
window.onresize = function (e) {
pad.resize(el.offsetWidth);
}
</script>
<!-- End Document
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
</body>
</html>