| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <style> | 2 <style> |
| 3 canvas { | 3 canvas { |
| 4 background-color: gray; | 4 background-color: gray; |
| 5 width: 200px; | 5 width: 100px; |
| 6 height: 200px; | 6 height: 100px; |
| 7 object-fit: contain; | 7 object-fit: contain; |
| 8 } | 8 } |
| 9 </style> | 9 </style> |
| 10 <p>Test passes if a green square inside an orange rectanlge is shown up without
a distortion. | 10 <p>Test passes if a green square inside a gray square is shown without distortio
n.</p> |
| 11 <div> | 11 <div> |
| 12 <canvas width="200" height="400"></canvas> | 12 <canvas width="50" height="100"></canvas> |
| 13 </div> | 13 </div> |
| 14 <script> | 14 <script> |
| 15 function paintCanvas(canvas) | 15 function paintCanvas(canvas) |
| 16 { | 16 { |
| 17 var ctx = canvas.getContext('2d'); | 17 var ctx = canvas.getContext('2d'); |
| 18 ctx.fillStyle = 'orange'; | |
| 19 ctx.fillRect(0, 0, canvas.width, canvas.height); | |
| 20 | |
| 21 ctx.fillStyle = 'green'; | 18 ctx.fillStyle = 'green'; |
| 22 var squarWidth = canvas.width / 2; | 19 ctx.fillRect(10, 35, 30, 30); |
| 23 ctx.fillRect(50, 150, squarWidth, squarWidth); | |
| 24 } | 20 } |
| 25 | 21 |
| 26 paintCanvas(document.querySelector('canvas')); | 22 paintCanvas(document.querySelector('canvas')); |
| 27 </script> | 23 </script> |
| OLD | NEW |