Skip to content

Instantly share code, notes, and snippets.

@JobLeonard
Last active December 10, 2024 13:07
Show Gist options
  • Save JobLeonard/1eec94b784fcc4266f04534f12593991 to your computer and use it in GitHub Desktop.
Save JobLeonard/1eec94b784fcc4266f04534f12593991 to your computer and use it in GitHub Desktop.
Firefox less than 128px canvas
/*bug-in-github-api-content-can-not-be-empty*/
<p>Using CSS to blow up a 21 by 11 pixel canvas to visible size, while keeping the individual pixels visible:</p>
<canvas width=21 height=11 style="image-rendering:pixelated;width:840;height:440px"></canvas>
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
ctx.fillStyle = "black";
ctx.fillRect(0, 0, 21, 11);
ctx.fillStyle = "white";
ctx.fillRect(1, 1, 9, 9);
ctx.fillRect(11, 1, 9, 9);
ctx.strokeStyle = ctx.fillStyle = "black";
ctx.lineWidth = 1;
ctx.beginPath();
ctx.arc(5.5, 5.5, 2.5, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(5.5, 5.5, 3.5, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(15.5, 5.5, 2.5, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(16, 6, 3.5, 0, Math.PI * 2);
ctx.stroke();
{"name":"Firefox less than 128px canvas","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