canvas_scale.html (764B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>Verify that canvases are scaled up to their computed size</title> 4 <link rel="match" href="canvas_scale_ref.html"> 5 <style> 6 canvas { 7 width: 20px; 8 height: 20px; 9 } 10 div { 11 line-height: 0; 12 } 13 </style> 14 <div><canvas width="16" height="16" data-color="#FF00FF"></canvas><canvas width="16" height="16" data-color="#00FF00"></canvas></div> 15 <div><canvas width="16" height="16" data-color="#0000FF"></canvas><canvas width="16" height="16" data-color="#FF00FF"></canvas></div> 16 <script> 17 var canvases = document.getElementsByTagName('canvas'); 18 for (var i = 0; i < canvases.length; i++) { 19 var ctx = canvases[i].getContext('2d'); 20 ctx.fillStyle = canvases[i].getAttribute('data-color'); 21 ctx.fillRect(0, 0, 16, 16); 22 } 23 </script>