1
0
Fork 0
firefox/testing/web-platform/tests/resize-observer/create-pattern-data-url.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

22 lines
580 B
JavaScript

const patternSize = 4;
export default function createPatternDataURL() {
const ctx = document.createElement('canvas').getContext('2d');
ctx.canvas.width = patternSize;
ctx.canvas.height = patternSize;
const b = [0, 0, 0, 255];
const t = [0, 0, 0, 0];
const r = [255, 0, 0, 255];
const g = [0, 255, 0, 255];
const imageData = new ImageData(patternSize, patternSize);
imageData.data.set([
b, t, t, r,
t, b, g, t,
t, r, b, t,
g, t, t, b,
].flat());
ctx.putImageData(imageData, 0, 0);
return {patternSize, dataURL: ctx.canvas.toDataURL()};
}