OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <style>* { margin: 0; padding: 0; }</style> |
| 3 <canvas id="canvas" width="200" height="200"></canvas> |
| 4 <script> |
| 5 var canvas = document.getElementById('canvas'); |
| 6 var ctx = canvas.getContext('2d'); |
| 7 var width = canvas.width; |
| 8 var height = canvas.height; |
| 9 |
| 10 ctx.globalCompositeOperation = 'lighter'; |
| 11 ctx.fillStyle = '#f00'; |
| 12 ctx.fillRect(0,0,width,height); |
| 13 |
| 14 gradient = ctx.createLinearGradient(0, 0, 0, height); |
| 15 gradient.addColorStop(0, "#0f0"); |
| 16 gradient.addColorStop(1, "#00f"); |
| 17 ctx.fillStyle = gradient; |
| 18 ctx.fillRect(0, 0, width, height); |
| 19 </script> |
OLD | NEW |