Created
April 18, 2018 04:28
-
-
Save haynesgt/eb9e2173f95495675c372cd274f16af8 to your computer and use it in GitHub Desktop.
Cross Fractal
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
document.body.innerHTML = ""; | |
var c = document.createElement("canvas"); | |
document.body.appendChild(c); | |
c.width = c.height = 1024; | |
var ctx = c.getContext("2d"); | |
var alpha = 3 / 8; | |
var beta = 1 - alpha; | |
ctx.strokeStyle = "#FF0000"; | |
for (n = 5; n <= 10; n++) { for (i = 0; i < c.width - 1; i += 2**n) for (j = 0; j < c.height - 1; j += 2**n) { ctx.moveTo(i + 2**(n-1), j + 2**(n) * alpha); ctx.lineTo(i + 2**(n-1), j + 2**n * beta); ctx.moveTo(i + 2**(n) * alpha, j + 2**(n - 1)); ctx.lineTo(i + 2**(n) * beta, j + 2**(n - 1)); } } | |
ctx.stroke(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment