-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.html
35 lines (32 loc) · 958 Bytes
/
example.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
<html>
<head>
<title>CanvasSaver example</title>
<script src="./canvassaver.js"></script>
</head>
<body>
<canvas id="drawhere" width="1600" height="1300" style="border: 1px solid #ccc"></canvas>
<script>
// get canvas reference
var cnvs = document.getElementById('drawhere');
var wid = 1600, hgt = 1300;
// draw some stuff on the canavs
var ctx = cnvs.getContext('2d');
ctx.fillStyle='#ffffff';
ctx.beginPath();
ctx.rect(0,0,wid,hgt);
ctx.fill();
ctx.closePath();
ctx.strokeStyle = '#996600';
for(var i=0; i<5000; i++) {
ctx.beginPath();
ctx.arc(Math.random()*wid, Math.random()*hgt, Math.random()*40+20, 0, 6.28);
ctx.stroke();
ctx.closePath();
}
// create the saver, and add the button to the DOM
var cs = new CanvasSaver('./saveme.php')
var btn = cs.generateButton('save an image!', cnvs, 'myimage');
document.body.insertBefore(btn, cnvs);
</script>
</body>
</html>