Code Sketch
Penguin
Category: Art
def circle(t: Turtle, radius: Int, c: Color) = runInBackground {
t.setSpeed(slow)
t.setFillColor(c)
t.setPenColor(c)
t.right(360, radius)
t.invisible()
}
def triangle(t: Turtle, size: Int, fill: Color, pen: Color) = runInBackground {
t.setSpeed(slow)
t.setFillColor(fill)
t.setPenColor(pen)
t.setPenThickness(1)
repeat(3) {
t.forward(size)
t.left(120)
}
t.invisible()
}
def square(t: Turtle, size: Int, fill: Color, pen: Color) = runInBackground {
t.setSpeed(slow)
t.setFillColor(fill)
t.setPenColor(pen)
t.setPenThickness(1)
repeat(4) {
t.forward(size)
t.right(90)
}
t.invisible()
}
def shape(t: Turtle, size: Int, c: Color) = runInBackground {
t.setSpeed(medium)
t.setFillColor(c)
t.setPenColor(c)
repeat(2) {
t.forward(size)
t.right(180, 50)
}
t.invisible()
}
def dot(t: Turtle, n: Int) = runInBackground {
t.setSpeed(slow)
t.setPenColor(black)
t.dot(n)
t.invisible()
}
clear()
invisible()
zoom(1.5)
val t1 = newTurtle(0, 0)
val t2 = newTurtle(10, 0)
val t3 = newTurtle(30, 80)
val t4 = newTurtle(70, 80)
val t5 = newTurtle(60, 80)
val t6 = newTurtle(-5, 60)
val t7 = newTurtle(105, 40)
val t8 = newTurtle(30, 100)
val t9 = newTurtle(70, 100)
val t10 = newTurtle(20, -60)
val t11 = newTurtle(60, -60)
shape(t1, 80, black)
circle(t2, 40, white)
t3.setHeading(180)
circle(t3, 18, white)
t4.setHeading(180)
circle(t4, 18, white)
t5.setHeading(180)
triangle(t5, 20, orange, black)
t6.setHeading(270)
triangle(t6, 20, black, white)
triangle(t7, 20, black, white)
dot(t8, 20)
dot(t9, 20)
square(t10, 20, orange, white)
square(t11, 20, orange, white)