Created
May 21, 2021 22:56
-
-
Save scruss/89d1b20b190274123ed13f005ec6af35 to your computer and use it in GitHub Desktop.
2d plotting on canvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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