So I'm trying to build a Mondrian art creator that allows you to create any number of cubes with a random size of what the cubes will be. I am able to create the random size, but the trouble I'm having is getting it to create more than two random cubes. I'm kinda a newb at python so sorry about that.
import turtle
import random
turtle.screensize(1000,1000)
turtle.setworldcoordinates(-500,-500,500,500)
piet = turtle.Turtle()
piet.speed(3)
#primary colors, red, blue, yellow
#piet.color(red,blue,yellow)
rectangles = int(input('How many rectangles should be drawn?'))
rectangle_w = int(input('What should be the max width of the rectangles?'))
rectangle_h = int(input('What should be the max height of the rectangles?'))
def mondrian(t,random_w,random_h):
for number_r in range(1):
for box in range(2):
t.left(90)
t.forward(random_w)
t.left(90)
t.forward(random_h)
mondrian(piet,random.randint(10,rectangle_w),random.randint(10,rectangle_h))
def repeat_mondrian():
while mondrian(piet,random.randint(10,rectangle_w),random.randint(10,rectangle_h)) < rectangles:
return False
repeat_mondrian()
Aucun commentaire:
Enregistrer un commentaire