wpt / css / css-paint-api / background-image-tiled.https.html

Status: PASS | Duration: 7ms | Subtests: 1/1 | Open test on wpt.live | Open ref on wpt.live | wpt.fyi

/css/css-paint-api/background-image-tiled.https.html

<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.css-houdini.org/css-paint-api/">
<link rel="match" href="background-image-tiled-ref.html">
<style>
    div {
        display: inline-block;
        width: 100px;
        height: 100px;
    }

    #one {
        background:
            paint(ellipse) top left/50% 50% repeat-x,
            paint(ellipse) bottom left/100% 50% no-repeat;
    }

    #two {
        background:
            paint(ellipse) top left/50% 20% repeat-y,
            paint(ellipse) center right/50% 50% no-repeat;
    }
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<body>
<div id="one"></div>
<div id="two"></div>

<script id="code" type="text/worklet">
registerPaint('ellipse', class {
    paint(ctx, geom) {
        ctx.fillStyle = 'green';
        ctx.beginPath();
        ctx.rect(0, 0, geom.width, geom.height);
        ctx.fill();
    }
});
</script>

<script>
    importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent);
</script>
</body>
</html>

/css/css-paint-api/background-image-tiled-ref.html

<!DOCTYPE html>
<html>
<body>
<canvas id ="one" width="100" height="100"></canvas>
<canvas id ="two" width="100" height="100"></canvas>
<script>
function drawCircle(ctx, geom) {
    ctx.fillStyle = 'green';
    ctx.beginPath();
    ctx.rect(0, 0, geom.width, geom.height);
    ctx.fill();
}

var ctx1 = document.getElementById('one').getContext('2d');
drawCircle(ctx1, {width: 50, height: 50});
ctx1.translate(50, 0);
drawCircle(ctx1, {width: 50, height: 50});
ctx1.resetTransform();
ctx1.translate(0, 50);
drawCircle(ctx1, {width: 100, height: 50});

var ctx2 = document.getElementById('two').getContext('2d');
for (var i = 0; i < 5; i++) {
    drawCircle(ctx2, {width: 50, height: 20});
    ctx2.translate(0, 20);
}
ctx2.resetTransform();
ctx2.translate(50, 25);
drawCircle(ctx2, {width: 50, height: 50});
</script>
</body>
</html>