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