Created
October 6, 2016 16:40
-
-
Save craftoid/d7062d5b91769d737d47f43eba0a28b9 to your computer and use it in GitHub Desktop.
Turtlewalk made from the Binary Digits of consecutive Numbers.
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
// @bitcraftlab 2016 | |
import processing.pdf.*; | |
int iter = 6; | |
int steps = 1 << (2 * iter); | |
float d = 2048.0 / steps; | |
float a = PI/2; | |
size(595, 842, PDF, "binary_digit_folding.pdf"); | |
background(255); | |
strokeWeight(d/2); | |
translate(225, 75); | |
rotate(-PI/2); | |
for (int i = 0; i < steps; i++) { | |
int b = i; | |
while (b > 0) { | |
int r = b % 2; | |
b /= 2; | |
rotate(r == 0 ? -a : +a); | |
line(0, 0, d, 0); | |
translate(d, 0); | |
print(r); | |
} | |
println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment