Skip to content

Instantly share code, notes, and snippets.

@greggman
Created April 13, 2024 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggman/766c4cb444d9cd56267067d5ad9e1b8c to your computer and use it in GitHub Desktop.
Save greggman/766c4cb444d9cd56267067d5ad9e1b8c to your computer and use it in GitHub Desktop.
Canvas2D: Clip mask isn't using the stencil?
canvas {
image-rendering: pixelated;
width: 640px;
height: 640px;
}
<canvas width="32" height="32"></canvas>
const ctx = document.querySelector("canvas").getContext("2d");
ctx.beginPath();
ctx.arc(16, 16, 10, 0, Math.PI * 2, true);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 64, 64);
{"name":"Canvas2D: Clip mask isn't using the stencil?","settings":{},"filenames":["index.html","index.css","index.js"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment