blob: 5d9a083a82ac216ed7b7e257e0204dca087caaa1 [file] [edit]
<html>
<body>
<canvas width="100" height="100" style="border: solid 1px gray"></canvas>
<script>
const iterations = 10;
const increment = 4;
const canvas = document.getElementsByTagName('canvas')[0];
const width = canvas.width;
const ctx = canvas.getContext('2d');
let region = new Path2D();
region.rect(width - 1, 0, 0, canvas.height);
ctx.clip(region);
ctx.font = "10px monospace";
ctx.fillStyle = "blue";
for (let i = 0; i < iterations; ++i) {
const x = width + (i - iterations / 2) * increment;
const y = i * 10;
ctx.fillText("Hi", x, y);
}
</script>
</body>
</html>