Code Sketch


Angry bird
By: Soham Dabral
Category: Art
// angry bird using pic.thatsXX transforms
// works with Kojo 2.9.18 and later

cleari()
//showAxes()
//showGrid()
def beak(n: Int) = Picture.fromVertexShape { s =>
    import s._
    beginShape()
    vertex(85, 35)
    vertex(50, 0)
    vertex(120, 0)
    vertex(85, 35)
    endShape()
}

def tail(n: Int) = Picture.fromVertexShape { s =>
    setPenThickness(4)
    setPenColor(black)
    setFillColor(black)
    beginShape()
    vertex(-150, 10)
    vertex(-180, 20)
    vertex(-200, 0)
    vertex(-180, -30)
    vertex(-130, -10)
    endShape()
}

def head(n: Int) = Picture.fromVertexShape { s =>
    import s._
    beginShape()
    vertex(0, 150)
    vertex(-30, 235)
    vertex(-60, 202)
    vertex(-40, 148)
    endShape()
}

def wp(n: Double) = Picture {
    right(90, n * 1.64)
    forward(105)
    right(90, n * 0.30)
    right(90, n * 1.5)
    //   /     forward(150)
    //    right(10, n * 0.75)
}

def spot(n: Int) = Picture {
    right(90, n * 2)
    forward(n / 2)
    right(90, n * 2)
    forward(n / 2)
    right(90, n * 2)
    forward(n / 2)
    right(90, n * 2)
    forward(n / 2)

}
val red = cm.radialGradient(30, 10, ColorMaker.hsl(0, 1.00, 0.86), 150, ColorMaker.hsl(0, 1.00, 0.28), false)
val white2 = cm.linearGradient(0, -50, ColorMaker.hsla(0, 0.00, 1.00, 0.76), -50, -100, ColorMaker.hsl(0, 1.00, 0.28), false)
val pic = Picture.circle(150)
    .withPenColor(noColor)
    .withFillColor(red)

val eye1 = Picture.circle(30)
    .withPenColor(black)
    .withTranslation(45, 30)
    .withFillColor(white)

val eye2 = Picture.circle(25)
    .withPenColor(black)
    .withTranslation(100, 30)
    .withFillColor(white)

val pupil1 = Picture.circle(10)
    .withPenColor(black)
    .withFillColor(black)
    .withTranslation(60, 30)

val pupil2 = Picture.circle(8)
    .withPenColor(black)
    .withFillColor(black)
    .withTranslation(90, 30)

val eyebrow1 = Picture.rectangle(50, 20)
    .withPenColor(black)
    .withFillColor(black)

val eyebrow2 = Picture.rectangle(40, 20)
    .withPenColor(black)
    .withFillColor(black)

val fb = picStack(
    beak(120),
    beak(120)
        .withFlippedY
)
val AB = picStack(
    pic
        .withPenThickness(4),
    eye1
        .withPenThickness(4),
    eye2
        .withPenThickness(4),
    pupil1
        .withPenThickness(4),
    pupil2
        .withPenThickness(4),
    eyebrow1
        .thatsRotated(-30)
        .thatsTranslated(10, 75)
        .withPenThickness(4),
    eyebrow2
        .thatsRotated(30)
        .thatsTranslated(80, 50)
        .withPenThickness(4),
    tail(100),
    head(100)
        .withPenColor(noColor)
        .withPenThickness(4)
        .withFillColor(red),
    wp(100)
        .thatsTranslated(-105, -175)
        .thatsScaled(0.75)
        .withPenColor(noColor)
        .withFillColor(white2),
    fb
        .withTranslation(-10, -15)
        .withPenColor(black)
        .withFillColor(yellow)
        .withPenThickness(4),
    spot(5)
        .withTranslation(-50, 0)
        .withPenColor(noColor)
        withFillColor (ColorMaker.hsla(0, 1.00, 0.17, 0.76)),
    spot(10)
        .withTranslation(-100, -5)
        .withPenColor(noColor)
        withFillColor (ColorMaker.hsla(0, 1.00, 0.17, 0.76))
)
draw(AB)