Skip to content

Instantly share code, notes, and snippets.

@scruss
Created May 21, 2021 22:56
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 scruss/89d1b20b190274123ed13f005ec6af35 to your computer and use it in GitHub Desktop.
Save scruss/89d1b20b190274123ed13f005ec6af35 to your computer and use it in GitHub Desktop.
2d plotting on canvas
<canvas id="c" width="1024" height="1024">
<script>
const context = c.getContext('2d');
for (let x = 0; x < 256; x++) {
let y = 255 - 4 * 256 * ((x / 256) - 0.5)**2;
context.fillRect(x*4, y*4, 4, 4);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment