| <canvas id="target" width="400" height="400"></canvas> |
| const targetCanvas = document.getElementById('target'); |
| const target = targetCanvas.getContext('2d'); |
| const canvasWidth = targetCanvas.width; |
| const canvasHeight = targetCanvas.height |
| var sourceCanvas = document.createElement('canvas'); |
| sourceCanvas.width = canvasWidth; |
| sourceCanvas.height = canvasHeight; |
| const source = sourceCanvas.getContext('2d'); |
| source.fillStyle = 'green'; |
| source.fillRect(0, 0, canvasWidth, canvasHeight); |
| const imagedata = source.getImageData(0, 0, canvasWidth, canvasHeight); |
| target.putImageData(imagedata, 0, 0, progressX, progressY, paintSize, paintSize); |
| if (progressX + paintSize <= canvasWidth) { |
| requestAnimationFrame(drawLoop); |
| if (progressY + paintSize > canvasHeight) { |
| requestAnimationFrame(drawLoop); |
| testRunner.waitUntilDone(); |
| requestAnimationFrame(drawLoop); |