from shapes import Triangle, Oval, Rectangle from random import randint rect1 = Rectangle() rect1.set_width(200) rect1.set_height(100) rect1.set_color("blue") rect2 = Rectangle() rect2.set_width(randint(10,150)) rect2.set_height(randint(10,150)) rect2.set_color("red") rect2.set_x(randint(0,400)) rect2.set_y(randint (0,400)) ovl1=Oval() ovl1.randomize() tri1 = Triangle() tri1.randomize()
from guizero import App, PushButton from shapes import Triangle, Rectangle, Oval, Paper def changeMe(): r.move(20, -20) t2.move(5, 0) app = App(width=600, height=600) button = PushButton(app, changeMe, text="Click me") p = Paper(app) t = Triangle(p) t.randomize() t.draw() t2 = Triangle(p) t2.randomize() t2.draw() r = Rectangle(p) r.randomize() r.width = 400 r.draw() r.color = 'red' r.width = 20 app.display()
rect1 = Rectangle() rect1.set_width(100) rect1.set_height(200) rect1.set_color('blue') rect1.draw() rect2 = Rectangle() rect2.set_width(50) rect2.set_height(150) rect2.set_color('red') rect2.set_x(100) rect2.set_y(100) rect2.draw() # Oval oval1 = Oval() oval1.set_color('white') oval1.set_x(30) oval1.set_y(90) oval1.draw() #Triangle tri = Triangle() tri.randomize() tri.set_color('blue') tri.draw()