Code Sketch
Tangram_Pictures
Category: Programming
cleari
//showGrid()
//showAxes()
setSpeed(superFast)
def square = Picture {
setPenColor(yellow)
setPenThickness(10)
forward(500)
right
forward(500)
right
forward(500)
right
forward(500)
right
}
def shape1 = Picture {
setFillColor(yellow)
right(135)
forward(141.42)
left(135)
forward(200)
left(135)
forward(141.42)
}.thatsStrokeColored(black)
def shape2 = Picture {
setFillColor(yellow)
right(135)
forward(141.42)
left(135)
forward(200)
left(135)
forward(141.42)
}.thatsStrokeColored(black)
def shape3 = Picture {
setFillColor(yellow)
right(135)
forward(70.71)
right(90)
forward(70.71)
right(90)
forward(70.71)
right(90)
forward(70.71)
right(90)
}.thatsStrokeColored(black)
def shape4 = Picture {
setFillColor(yellow)
right()
forward(100)
left(135)
forward(70.71)
left(90)
forward(70.71)
}.thatsStrokeColored(black)
def shape5 = Picture {
setFillColor(yellow)
left(45)
forward(70.71)
left(135)
forward(100)
left(135)
forward(70.71)
}.thatsStrokeColored(black)
def shape6 = Picture {
setFillColor(yellow)
forward(100)
right(135)
forward(70.71)
right(45)
forward(100)
right(135)
forward(70.71)
}.thatsStrokeColored(black)
def shape7 = Picture {
setFillColor(yellow)
left(45)
forward(141.42)
left(135)
forward(100)
left(90)
forward(100)
}.thatsStrokeColored(black)
def whale = picStack(
Picture {},
shape5.withFlippedX.thatsRotated(90).thatsTranslated(70.71, -70.71).withFillColor(blue),
shape1.thatsRotated(45).thatsTranslated(0, -(70.71 + 70.71)).withFillColor(blue),
shape1.thatsRotated(-135).thatsTranslated(0, 0).withFillColor(blue),
shape6.withFlippedX.thatsRotated(180).thatsTranslated(140, -40).withFillColor(blue),
shape6.thatsRotated(45).thatsTranslated(-70.71, -141.42).withFillColor(blue),
shape5.withFlippedX.thatsRotated(90).thatsTranslated(189, 10).withFillColor(blue)
)
def duck = picStack(
Picture {},
shape3.withFillColor(yellow).thatsRotated(-45),
shape5.withFillColor(yellow).thatsRotated(45).thatsTranslated(0, -70.71),
shape1.withFillColor(yellow).thatsRotated(45).thatsTranslated(0, -(70.71 + 70.71)),
shape1.withFillColor(yellow).thatsRotated(90).thatsTranslated(100, -100),
shape6.withFillColor(yellow).withFlippedX.thatsRotated(-45),
shape7.withFillColor(yellow).thatsRotated(-135).thatsTranslated(-70.71, 70.71),
shape4.withFillColor(yellow).thatsRotated(-45).thatsTranslated(0, 141.42)
)
def bird = picStack(
Picture {},
shape3.thatsFilledWith(yellow).thatsRotated(-45),
shape7.thatsFilledWith(yellow).thatsRotated(135),
shape6.thatsFilledWith(yellow).withFlippedY.thatsRotated(135).thatsTranslated(-70, -70).withFlippedX,
shape5.thatsFilledWith(orange).thatsRotated(45).thatsTranslated(-70, 0),
shape4.thatsFilledWith(red).thatsTranslated(-240, 0),
shape1.thatsFilledWith(red).thatsRotated(-90).thatsTranslated(-40, 100),
shape1.thatsFilledWith(orange).withFlippedY.thatsTranslated(0, -60).thatsRotated(90)
)
def dog = picStack(
Picture {},
shape1.thatsRotated(45),
shape3.thatsRotated(45),
shape4.thatsRotated(135).thatsTranslated(210, -70),
shape1.thatsRotated(-135).thatsTranslated(211, 72),
shape4.thatsRotated(45).thatsTranslated(210, 70),
shape6.thatsRotated(-45).withFlippedX.thatsTranslated(0, 140),
shape7.thatsRotated(-135).thatsTranslated(-140, 69)
)
def fish = picStack(
Picture {},
shape1.withFlippedX.thatsRotated(180).thatsTranslated(-100, 0).thatsFilledWith(gray),
shape3.thatsRotated(-45).thatsTranslated(70.71, 70.71).thatsFilledWith(gray),
shape4.thatsRotated(225).thatsTranslated(70.71, 141.42).thatsFilledWith(gray),
shape5.thatsRotated(45).thatsTranslated(70.71, 0).thatsFilledWith(gray),
shape6.withFlippedY.thatsRotated(45).thatsTranslated(0, -70).thatsFilledWith(gray),
shape1.thatsRotated(180).thatsTranslated(170, 0).thatsFilledWith(gray),
shape7.thatsRotated(135).withFlippedX.thatsTranslated(240, 70.71).thatsFilledWith(gray),
)
def Rooster = picStack(
Picture {},
shape1.withFlippedX.thatsRotated(45).thatsTranslated(0, 0).thatsFilledWith(red),
shape1.thatsRotated(-45).thatsTranslated(0, 70).thatsFilledWith(red),
shape3.thatsRotated(45).thatsTranslated(-140, 70).thatsFilledWith(yellow),
shape4.thatsRotated(0).thatsTranslated(-170, 70).thatsFilledWith(red),
shape5.thatsRotated(0).thatsTranslated(-40, -100).thatsFilledWith(brown),
shape6.thatsRotated(-225).thatsTranslated(140, 0).thatsFilledWith(blue),
shape7.thatsRotated(225).thatsTranslated(0, 70).thatsFilledWith(orange),
)
def House = picStack(
Picture {},
shape1.thatsRotated(-90).thatsTranslated(30, 100).thatsFilledWith(black),
shape1.thatsRotated(-90).thatsTranslated(0, 0).thatsFilledWith(black),
shape3.thatsRotated(45).thatsTranslated(-70, 140).thatsFilledWith(black),
shape4.thatsRotated(90).thatsTranslated(100, -100).thatsFilledWith(black),
shape5.thatsRotated(90).withFlippedY.thatsTranslated(50, -50).thatsFilledWith(black),
shape6.thatsRotated(45).withFlippedX.thatsTranslated(-70, 0).thatsFilledWith(black),
shape7.thatsRotated(270).thatsTranslated(-100, -100).thatsFilledWith(black),
)
def camel = picStack(
Picture {},
shape4.thatsFilledWith(red).withFlippedY,
shape5.thatsFilledWith(brown).withFlippedX.thatsTranslated(50, -50),
shape6.thatsFilledWith(brown).thatsTranslated(50, -150),
shape1.thatsFilledWith(brown).thatsRotated(180).thatsTranslated(200, -200),
shape1.thatsFilledWith(brown).withFlippedX.thatsRotated(45).thatsTranslated(141.42 + 150.0, -150),
shape3.thatsFilledWith(brown).thatsTranslated(150, -50),
shape7.thatsFilledWith(brown).thatsRotated(-135).thatsTranslated(150, -150)
)
whale.thatsTranslated(-300, 300).draw
bird.thatsTranslated(300, 300).draw
duck.thatsTranslated(-300, -600).draw
fish.thatsTranslated(-350, -250).draw
Rooster.thatsTranslated(300, -240).draw
camel.thatsTranslated(140, -500).draw
House.draw
hop(500)
setPenThickness(6)
setFillColor(cyan)
right()
forward(500)
right()
forward(1400)
right()
forward(1000)
right()
forward(1400)
right()
forward(500)