Neighboorhoods

Introduction

Students were instructed to create a function called drawHouse that should take at least 5 parameters:

They were encouraged to be creative and add additional parameters to change the colors, or other features of their houses. Finally, they were asked to create a neighboorhood of houses all created using their drawHouse function.

Student Graphics

  def drawHouse (window,x,y,width,height,color1,color2,color3,color4,color5,color6):
    #base
    r = Rectangle(Point(x,y),Point(x+width,y-height))
    r.draw(win)
    r.setFill(color1)
    r.setOutline(color1)
    #roof
    t = Polygon(Point(x,y),Point(x+width,y),Point(x+(width/2),y+(height/3)))
    t.draw(win)    
    t.setFill(color2)
    t.setOutline(color2)
    #door
    d = Rectangle(Point((x+width/3),y-(3*height/5)),Point(x+(2*width/3),y-height))
    d.draw(win)
    d.setFill(color3)
    d.setOutline(color3)
    #windows
    w = Rectangle(Point((x+width/9),(y-height/3)),Point((x+width/3),(y-height/8)))
    w.draw(win)
    w.setFill(color4)
    w.setOutline(color4)
    w2 = Rectangle(Point((x+5*width/8),(y-height/2)),Point((x+7*width/8),(y-height/4)))
    w2.draw(win)
    w2.setFill(color5)
    w2.setOutline(color5)
    #door knob
    center = Point((x+6*width/10),(y-8*height/10))
    radius = width/22
    c = Circle(center,radius)
    c.draw(win)
    c.setFill(color6)
    c.setOutline(color6)
More Examples