OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head></head> |
| 4 <body> |
| 5 <canvas id="mycanvas" width="600" height="400"></canvas> |
| 6 <script> |
| 7 if (window.testRunner) |
| 8 testRunner.dumpAsText(true); |
| 9 |
| 10 var canvas = document.getElementById('mycanvas'); |
| 11 var ctx = canvas.getContext('2d'); |
| 12 |
| 13 ctx.lineWidth = 3; |
| 14 ctx.strokeStyle = 'rgba(0, 0, 0, 0.5)'; |
| 15 |
| 16 // 20 angles. |
| 17 var sweepAngles = [ |
| 18 -123.7, -2.3, -2, -1, -0.3, -0.000001, 0, 0.000001, 0.3, 0.7, |
| 19 1, 1.3, 1.5, 1.7, 1.99999, 2, 2.00001, 2.3, 4.3, 3934723942837.3 |
| 20 ]; |
| 21 for (var i = 0; i < sweepAngles.length; i++) { |
| 22 sweepAngles[i] = sweepAngles[i] * Math.PI; |
| 23 } |
| 24 |
| 25 var startAngles = [ |
| 26 -1, -0.5, 0, 0.5 |
| 27 ] |
| 28 for (var i = 0; i < startAngles.length; i++) { |
| 29 startAngles[i] = startAngles[i] * Math.PI; |
| 30 } |
| 31 |
| 32 var startAngle = 0; |
| 33 var anticlockwise = false; |
| 34 var sign = 1; |
| 35 for (var i = 0; i < startAngles.length * 2; i++) { |
| 36 if (i == startAngles.length) { |
| 37 anticlockwise = true; |
| 38 sign = -1; |
| 39 } |
| 40 startAngle = startAngles[i % startAngles.length] * sign; |
| 41 ctx.save(); |
| 42 for (var j = 0; j < sweepAngles.length; j++) { |
| 43 ctx.save(); |
| 44 ctx.beginPath(); |
| 45 ctx.moveTo(0, 2); |
| 46 ctx.arc(18, 15, 10, startAngle, startAngle + (sweepAngles[j] * sign), an
ticlockwise); |
| 47 ctx.lineTo(0, 28); |
| 48 ctx.stroke(); |
| 49 ctx.restore(); |
| 50 ctx.translate(30, 0); |
| 51 } |
| 52 ctx.restore(); |
| 53 ctx.translate(0, 40); |
| 54 } |
| 55 |
| 56 </script> |
| 57 </body> |
| 58 </html> |
| 59 |
OLD | NEW |