Code Sketch


Fence
By: Anusha Pant
Category: Art
toggleFullScreenCanvas()
cleari()
setBackgroundH( Color(0, 204, 255), Color(0, 0, 102))
val t1 = newTurtle(-25, -150)
val t2 = newTurtle(-175, -150)
val t3 = newTurtle(125, -150)
val t4 = newTurtle(-325, -150)
val t5 = newTurtle(275, -150)
val t6 = newTurtle(-350, -25)
val t7 = newTurtle(-350, -100)
val t8 = newTurtle(-525, 150)
val t9 = newTurtle(400, 150)
val t10 = newTurtle(-700, -450)
def fence(t: Turtle) {
    t.setPenColor(black)
    t.setFillColor(white)
    t.forward(200)
    t.right(45)
    t.forward(25)
    t.right(-270)
    t.forward(25)
    t.right(45)
    t.forward(200)
    t.right()
    t.forward(35)
}
def rect(t: Turtle) {
    t.setPenColor(black)
    t.setFillColor(white)
    repeat(2) {
        t.forward(35)
        t.right()
        t.forward(685)
        t.right()
    }
}
t1.act { self => // we give this turtle the name 'self' within act {...}
    t1.invisible()
    fence(self)
}
t2.act { self => // we give this turtle the name 'self' within act {...}
    t2.invisible()
    fence(self)
}
t3.act { self => // we give this turtle the name 'self' within act {...}
    t3.invisible()
    fence(self)
}
t4.act { self => // we give this turtle the name 'self' within act {...}
    t4.invisible()
    fence(self)
}
t5.act { self => // we give this turtle the name 'self' within act {...}
    t5.invisible()
    fence(self)
}
t6.act { self => // we give this turtle the name 'self' within act {...}
    t6.invisible()
    pause(5)
    rect(t6)
}
t7.act { self => // we give this turtle the name 'self' within act {...}
    t7.invisible()
    pause(5)
    rect(t7)
}
t8.act { self => // we give this turtle the name 'self' within act {...}
    t8.invisible()    
    pause(12)
    t8.setFillColor(orange)
    t8.setPenColor(black)
    repeat (360) {
        t8.forward(1)
        t8.right(1)
    }
}
t9.act { self => // we give this turtle the name 'self' within act {...}
    t9.invisible()    
    pause(12)
    t9.setFillColor(Color(226, 221, 221))
    t9.setPenColor(black)
    repeat (360) {
        t9.forward(1)
        t9.right(1)
    }
}
t10.act { self => // we give this turtle the name 'self' within act {...}
    t10.setAnimationDelay(0)
    t10.setFillColor(Color(0, 204, 0))
    t10.setPenColor(green)
    t10.invisible()
    repeat (2) {
        t10.forward(295)
        t10.right()
        t10.forward(1400)
        t10.right()
    }
}