Skip to content

Instantly share code, notes, and snippets.

@meganehouser
Last active December 2, 2019 15:29
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 meganehouser/fbc7a7ba42b91fe1416cbb82a46fd36c to your computer and use it in GitHub Desktop.
Save meganehouser/fbc7a7ba42b91fe1416cbb82a46fd36c to your computer and use it in GitHub Desktop.
snowflake
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