Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
michael@0 | 1 | <body bgcolor="orange"> |
michael@0 | 2 | <canvas width="300" height="300" id="testcase-canvas" style="display:none"></canvas> |
michael@0 | 3 | <canvas width="300" height="300" id="testcase-canvas-dest"></canvas> |
michael@0 | 4 | <script> |
michael@0 | 5 | const kShadow = "rgba(00%, 0%, 0%, 1)"; |
michael@0 | 6 | const kTransparent = "rgba(0%, 100%, 100%, 0.5)"; |
michael@0 | 7 | |
michael@0 | 8 | var cx, g; |
michael@0 | 9 | |
michael@0 | 10 | cx = document.getElementById('testcase-canvas').getContext('2d'); |
michael@0 | 11 | |
michael@0 | 12 | cx.fillStyle = kShadow; |
michael@0 | 13 | cx.fillRect(100, 50, 150, 50); |
michael@0 | 14 | |
michael@0 | 15 | g = cx.createLinearGradient(0, 50, 0, 0); |
michael@0 | 16 | g.addColorStop(0, kShadow); |
michael@0 | 17 | g.addColorStop(0.2, kTransparent); |
michael@0 | 18 | g.addColorStop(1, kTransparent); |
michael@0 | 19 | cx.fillStyle = g; |
michael@0 | 20 | cx.fillRect(100, 0, 150, 50); |
michael@0 | 21 | |
michael@0 | 22 | g = cx.createRadialGradient(100, 100, 50, 100, 100, 100); |
michael@0 | 23 | g.addColorStop(0, kShadow); |
michael@0 | 24 | g.addColorStop(0.2, kTransparent); |
michael@0 | 25 | g.addColorStop(1, kTransparent); |
michael@0 | 26 | cx.fillStyle = g; |
michael@0 | 27 | cx.beginPath(); |
michael@0 | 28 | cx.arc(100, 100, 100, Math.PI * 0.5, Math.PI * 1.5); |
michael@0 | 29 | cx.fill(); |
michael@0 | 30 | |
michael@0 | 31 | cx2 = document.getElementById('testcase-canvas-dest').getContext('2d'); |
michael@0 | 32 | // draw a chunk of the gradients from above onto testcase-canvas-dest |
michael@0 | 33 | cx2.drawImage(document.getElementById('testcase-canvas'),45,20, 100,20 ,0,0, 100,20); |
michael@0 | 34 | </script> |
michael@0 | 35 | |
michael@0 | 36 | </window> |