I want to create a random rectangle on my rectangle class.
I have a function def randomRects(x,y,width,height)
: (x, y) is the top left corner and width must be less than 90, height less than 70.
I understand to create a random rectangle you have to do something like canvas.create_rectangle(x1,x2,y1,y1)
, but I'm not sure how to do it in this situation. I'm also not sure if width and height should be in parameters or not.
import random
class Rectangle:
def __init__(self, height, width):
self.height = 80
self.width = 100
#not sure if above is correct
def randomRects(x,y,width, height):
w = random.randrange(100)
h = random.randrange(80)
w.create_rectangle(x,y,width,height)
h.create_rectangle(x,y,width,height)
Aucun commentaire:
Enregistrer un commentaire