Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<title>Canvas test: 2d.gradient.radial.transform.translated.repeat</title>
<h1>2d.gradient.radial.transform.translated.repeat</h1>
<p class="desc">Filling with the same radial gradient under different translations draws each gradient at its own position</p>
<canvas id="canvas" width="300" height="300">
<p class="fallback">FAIL (fallback content)</p>
</canvas>
<script>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext('2d');
for (let i = 0; i < 3; i++) {
const x = 20 + i * 90;
ctx.save();
ctx.beginPath();
ctx.rect(x, 50, 80, 80);
ctx.clip();
const g = ctx.createRadialGradient(x + 30, 80, 0, x + 40, 90, 40);
g.addColorStop(0, 'rgb(180, 180, 230)');
g.addColorStop(1, 'rgb(40, 40, 110)');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 300, 300);
ctx.restore();
}
</script>