mercredi 28 janvier 2015

Python:Trying to make a circle at a random spot, with a random radius, that is filled randomly with a set of given color. Stuck on color part

# Heres what I have so far. The colorCircle(myTurtle) doesn't seem to work and I don't really know what to do. Kinda of an amateur, any tips would be appreciated.



def drawPolygon(myTurtle,sideLength,numSides):
turnAngle = 360/numSides
for i in range(numSides):
myTurtle.forward(sideLength)
myTurtle.right(turnAngle)

def drawCircle(myTurtle,radius):
circumference = 2 * 3.1415 * radius
sideLength = circumference / 360
drawPolygon(myTurtle, sideLength, 360)

def colorCircle(myTurtle):
x = random.random()
y = random.random()
myTurtle.up()
myTurtle.goto(x,y)
myTurtle.down()
radius = random.random()
color = [('white',0),('yellow',1),('green',2),('blue',3),('purple',4),('red',5),('black',6),('magenta',7),('pink',8),('brown',9)]
random.randint(0,9)
myTurtle.begin_fill(color)
drawCircle(myTurtle)




Aucun commentaire:

Enregistrer un commentaire