| <!DOCTYPE html> |
| |
| <html> |
| <head> |
| <title>object-fit on canvas</title> |
| <style type="text/css"> |
| img, embed, object, input, canvas, video { |
| width: 72px; |
| height: 72px; |
| margin: 2px 10px; |
| border: 1px solid black; |
| background-color: gray; |
| } |
| |
| .group { object-fit: contain; } |
| .group > *:nth-child(1) { object-fit: fill; } |
| .group > *:nth-child(2) { object-fit: contain; } |
| .group > *:nth-child(3) { object-fit: cover; } |
| .group > *:nth-child(4) { object-fit: none; } |
| .group > *:nth-child(5) { object-fit: scale-down; } |
| .group > *:nth-child(6) { object-fit: inherit; } |
| .group > *:nth-child(7) { } |
| </style> |
| <script type="text/javascript" charset="utf-8"> |
| if (window.testRunner) |
| testRunner.waitUntilDone(); |
| |
| var circlesImage; |
| |
| function paintCanvas(canvas) |
| { |
| var ctx = canvas.getContext('2d'); |
| ctx.drawImage(circlesImage, 0, 0); |
| } |
| |
| function init() |
| { |
| circlesImage = new Image() |
| circlesImage.addEventListener('load', imageLoaded, false); |
| circlesImage.src = "../resources/circles-landscape.png"; |
| } |
| |
| function imageLoaded() |
| { |
| var canvases = document.getElementsByTagName('canvas'); |
| for (var i = 0; i < canvases.length; ++i) |
| paintCanvas(canvases[i]) |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| window.addEventListener('load', init, false); |
| </script> |
| </head> |
| <body> |
| |
| <div class="group"> |
| <canvas width="288" height="144"></canvas> |
| <canvas width="288" height="144"></canvas> |
| <canvas width="288" height="144"></canvas> |
| <canvas width="288" height="144"></canvas> |
| <canvas width="288" height="144"></canvas> |
| <canvas width="288" height="144"></canvas> |
| <canvas width="288" height="144"></canvas> |
| </div> |
| |
| </body> |
| </html> |