snow2 - #for i in range(3 for j in range(3 use i,j to find...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#for i in range (3): # for j in range(3): # use i,j to find center # Program to make snowflake! # Local graphics module. Must be in same folder as this # program (or both on Desktop) import ecs10graphics as gr # Math module that comes with Python import math import random as random def pointOnCircle(f, r): # f is fraction of the way around # r is radius # produces a point f way around circle c,r # Use the global variable "center". c = center a = (2*math.pi)*f + math.pi/2.0 x = c[0] + math.cos(a)*r y = c[1] + math.sin(a)*r return [x,y] def circleSegment(f1, f2, r1, r2): # f1 is first fraction, r1 first radius # f2 is second fraction, r2 second radius # draws a segment from point f1, r1 to point f2, r2 p1 = pointOnCircle(f1, r1) p2 = pointOnCircle(f2, r2) gr.line(p1[0], p1[1], p2[0], p2[1], lineWidth=3) def drawBothLines(frac,s1, s2, r1, r2): circleSegment(frac+s1, frac+s2, r1, r2) circleSegment(frac-s1, frac-s2, r1, r2) #call by: drawBothLines(frac, .05, .05, 100) def snowman(): gr.set_Color(gr.Color.white)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2010 for the course ECS 40175 taught by Professor Amenta during the Fall '09 term at UC Davis.

Page1 / 2

snow2 - #for i in range(3 for j in range(3 use i,j to find...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online