OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <canvas id ='output' width='200' height='400'></canvas> | 4 <canvas id ="output" width="300" height="400"></canvas> |
5 <script> | 5 <script> |
6 var aCanvas = document.getElementById('output'); | 6 var canvas = document.getElementById('output'); |
7 var ctx = aCanvas.getContext('2d'); | 7 var ctx = canvas.getContext('2d'); |
| 8 |
8 ctx.beginPath(); | 9 ctx.beginPath(); |
9 ctx.lineWidth = '10'; | 10 ctx.lineWidth = '10'; |
10 ctx.strokeStyle = 'green'; | 11 ctx.strokeStyle = 'green'; |
11 ctx.lineJoin = 'round'; | |
12 ctx.moveTo(15, 15); | 12 ctx.moveTo(15, 15); |
13 ctx.lineTo(135, 15); | 13 ctx.lineTo(135, 15); |
14 ctx.lineTo(70, 170); | 14 ctx.lineTo(70, 170); |
15 ctx.closePath(); | 15 ctx.closePath(); |
16 ctx.stroke(); | 16 ctx.stroke(); |
17 | 17 |
18 var path1 = new Path2D(); | 18 var path1 = new Path2D(); |
19 path1.moveTo(150, 25); | 19 path1.moveTo(250, 25); |
20 path1.bezierCurveTo(10, 150, 10, 300, 100, 200); | 20 path1.bezierCurveTo(110, 150, 110, 300, 200, 200); |
21 ctx.strokeStyle = 'purple'; | 21 ctx.strokeStyle = 'purple'; |
22 ctx.setLineDash([ 10, 5 ]); | 22 ctx.setLineDash([ 10, 5 ]); |
23 ctx.stroke(path1); | 23 ctx.stroke(path1); |
24 | 24 |
25 ctx.fillStyle = 'red'; | 25 ctx.fillStyle = 'red'; |
26 ctx.beginPath() | 26 ctx.beginPath() |
27 ctx.arc(75, 325, 50, 0, Math.PI * 2, true); | 27 ctx.arc(75, 325, 50, 0, Math.PI * 2, true); |
28 ctx.arc(75, 325, 20, 0, Math.PI * 2, true); | 28 ctx.arc(75, 325, 20, 0, Math.PI * 2, true); |
29 ctx.fill("evenodd"); | 29 ctx.fill('evenodd'); |
30 </script> | 30 </script> |
31 </body> | 31 </body> |
32 </html> | 32 </html> |
OLD | NEW |