Code Sketch
Tangram shapes
clear
//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(blue)
def shape2 = Picture{
setFillColor(yellow)
right(135)
forward(141.42)
left(135)
forward(200)
left(135)
forward(141.42)
}.thatsStrokeColored(blue)
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(blue)
def shape4 = Picture{
setFillColor(yellow)
right()
forward(100)
left(135)
forward(70.71)
left(90)
forward(70.71)
}.thatsStrokeColored(blue)
def shape5 = Picture{
setFillColor(yellow)
left(45)
forward(70.71)
left(135)
forward(100)
left(135)
forward(70.71)
}.thatsStrokeColored(blue)
def shape6 = Picture{
setFillColor(yellow)
forward(100)
right(135)
forward(70.71)
right(45)
forward(100)
right(135)
forward(70.71)
}.thatsStrokeColored(blue)
def shape7 = Picture {
setFillColor(yellow)
left(45)
forward(141.42)
left(135)
forward(100)
left(90)
forward(100)
}.thatsStrokeColored(blue)
def squaresBoxes = picStack(
Picture {},
square.thatsTranslated(0, 0).thatsFilledWith(black),
square.thatsTranslated(500, 0).thatsFilledWith(black),
square.thatsTranslated(500, 0).withFlippedY.thatsFilledWith(black),
square.thatsTranslated(0, 0).withFlippedY.thatsFilledWith(black),
square.thatsTranslated(0, 0).withFlippedX.thatsFilledWith(black),
square.thatsTranslated(-500,-500).thatsFilledWith(black)
)
squaresBoxes.draw
def fish = picStack(
Picture{},
shape1.thatsRotated(135),
shape1.thatsRotated(135).withFlippedY,
shape3.thatsRotated(45).thatsTranslated(0, 40),
shape4.thatsRotated(135).thatsTranslated(70, 40),
shape4.thatsRotated(45).thatsTranslated(0, -100),
shape6.thatsRotated(-45).withFlippedX.thatsTranslated(140, -30),
shape7.thatsRotated(-45).thatsTranslated(140, -30)
)
def tree =picStack(
Picture {},
shape3.thatsRotated(45),
shape1.thatsRotated(-90).thatsTranslated(-20, 100),
shape6.thatsRotated(-90).withFlippedX.thatsTranslated(130, 50),
shape4.thatsTranslated(30, 50),
shape4.thatsRotated(180).thatsTranslated(80, 100),
shape1.thatsRotated(-90).thatsTranslated(30, 200),
shape7.thatsRotated(-135).thatsTranslated(-40, 200),
)
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 heart = picStack(
Picture{},
shape1.thatsRotated(90),
shape1.thatsRotated(-90).thatsTranslated(0, 200),
shape3.thatsTranslated(100, 200),
shape4.thatsRotated(180).thatsTranslated(100, 0),
shape6.withFlippedX.thatsTranslated(150, 50),
shape4.thatsRotated(-90).thatsTranslated(150, 150),
shape7.withFlippedX.thatsTranslated(0, 0)
)
def aeroplane = picStack(
Picture {},
shape4.thatsRotated(0).thatsTranslated(-50, -50),
shape6.thatsRotated(90).thatsTranslated(-50, -50),
shape1.withFlippedX.thatsRotated(45).thatsTranslated(140, 0),
shape1.withFlippedY.thatsRotated(135).thatsTranslated(140, 0),
shape3.thatsRotated(45).thatsTranslated(140, 30),
shape4.thatsRotated(45).thatsTranslated(210, -41),
shape7.thatsRotated(90).thatsTranslated(280, 130)
)
def mountain = picStack(
Picture{},
shape1.thatsRotated(135),
shape1.thatsRotated(45).thatsTranslated(140, 0),
shape3.thatsTranslated(70, 150),
shape4.thatsRotated(135).thatsTranslated(140, 0),
shape6.thatsRotated(135).withFlippedX.thatsTranslated(0, 70),
shape4.thatsRotated(135).thatsTranslated(70, 0),
shape7.thatsRotated(-45).thatsTranslated(140, 0)
)
fish.thatsTranslated(-300, 300).draw
tree.thatsTranslated(240, 200).draw
dog.thatsTranslated(650, 200).draw
heart.thatsTranslated(-300,-300).draw
mountain.thatsTranslated(650, -300).draw
aeroplane.thatsTranslated(200, -200).draw