OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <canvas id ="output" width="100" height="100"></canvas> | 4 <canvas id ="output" width="100" height="100"></canvas> |
5 <script> | 5 <script> |
6 var canvas = document.getElementById('output'); | 6 var canvas = document.getElementById('output'); |
7 var ctx = canvas.getContext('2d'); | 7 var ctx = canvas.getContext('2d'); |
8 | 8 |
9 var colors = ['red', 'green', 'blue']; | 9 var colors = ['red', 'green', 'blue']; |
10 for (var i = 2; i >= 0; i--) { | 10 for (var i = 2; i >= 0; i--) { |
11 ctx.fillStyle = colors[i]; | 11 ctx.fillStyle = colors[i]; |
12 ctx.fillRect(i * 20, i * 20, 40, 40); | 12 ctx.fillRect(i * 20, i * 20, 40, 40); |
13 } | 13 } |
14 </script> | 14 </script> |
15 </body> | 15 </body> |
16 </html> | 16 </html> |
OLD | NEW |