Основной эскиз
from windowsketch import * def setup(): size(800,200) global window_1 window_1 = Window(10,10,12,30, color(255,255,255)) print window_1.windowWidth print window_1.area() global buildingWindows buildingWindows = [] for w in xrange(5, 150, 5): #start of range, end of range, step window = Window(w*10, 100,w,90,color(255,255,255)) buildingWindows.append(window) def draw(): background(216, 201, 84) # window_1.draw() for window in buildingWindows: window.draw()
В классе окна:
class Window(object): def __init__(self, x, y, windowWidth, windowHeight, glazing): self.x = x self.y = y self.windowWidth = windowWidth self.windowHeight = windowHeight self.glazing = glazing def area(self): return self.windowWidth * self.windowHeight def draw(self): # fill(self.glazing) # rect(10, 10, 10 + self.windowWidth, 10 + self.windowHeight) #Letters textSize(32) text("Hide and Seek in a woods", 20, 40) fill(0, 102, 153) if self.x < mouseX and mouseX < self.x + self.windowWidth: fill(0) #drawing a body fill(226, 96, 63) rect(self.x+17, self.y+30, 8, 40) #legs line(self.x+17, self.y+20, self.x+17, self.y+90) line(self.x+25, self.y+20, self.x+25, self.y+90) #arms line(self.x+19, self.y+20, self.x+13, self.y+72) line(self.x+22, self.y+20, self.x+28, self.y+72) #drawing the face fill(226, 96, 63) ellipse(self.x + 20,self.y + 30,20,20) stroke(255, 255, 255) fill(255, 0, 0) ellipse(self.x + 14,self.y + 29,5,5) ellipse(self.x + 24,self.y + 29,5,5) noFill() else: fill(self.glazing) fill(37, 109, 33) ellipse(self.x, self.y, 20 + self.windowWidth, self.windowHeight) fill(198, 165, 57) rect(self.x, self.y, self.windowWidth/3-5, self.windowHeight)