Last active
December 2, 2019 15:29
-
-
Save meganehouser/fbc7a7ba42b91fe1416cbb82a46fd36c to your computer and use it in GitHub Desktop.
snowflake
This file contains hidden or 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
def draw_branch(branch_len, direction): | |
pushMatrix() | |
rotate(direction * PI / 3) | |
line(0, 0, branch_len, 0) | |
popMatrix() | |
def setup(): | |
size(500, 500) | |
background(30, 30, 255) | |
strokeCap(ROUND) | |
strokeWeight(5) | |
stroke(255,255,255, 180) | |
center = width / 2, height / 2 | |
translate(center[0], center[1]) | |
seeds = [(random(200), random(170)) for _ in range(3)] | |
for _ in range(6): | |
line(0, 0, 200, 0) | |
for (segment_len, branch_len) in seeds: | |
pushMatrix() | |
translate(segment_len, 0) | |
draw_branch(branch_len, 1) | |
draw_branch(branch_len, -1) | |
popMatrix() | |
rotate(PI / 3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment