Code Sketch
Tangram
Category: Art
cleari
showAxes()
showGrid()
def shape3 = Picture{
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{
right()
forward(100)
left(135)
forward(70.71)
left(90)
forward(70.71)
}.thatsStrokeColored(black)
def shape1 = Picture{
right(135)
forward(141.42)
left(135)
forward(200)
left(135)
forward(141.42)
}.thatsStrokeColored(black)
def shape5 = Picture{
left(45)
forward(70.71)
left(135)
forward(100)
left(135)
forward(70.71)
}.thatsStrokeColored(black)
def shape6 = Picture{
forward(100)
right(135)
forward(70.71)
right(45)
forward(100)
right(135)
forward(70.71)
}.thatsStrokeColored(black)
def shape7 = Picture {
left(45)
forward(141.42)
left(135)
forward(100)
left(90)
forward(100)
}.thatsStrokeColored(black)
def tangramDuck = picStack(
Picture {},
shape3.thatsRotated(-45).thatsFilledWith(Color(0, 120, 22)),
shape5.thatsRotated(45).thatsTranslated(0, -70.71).thatsFilledWith(purple),
shape1.thatsRotated(45).thatsTranslated(0, -(70.71+70.71)).thatsFilledWith(red),
shape1.thatsRotated(90).thatsTranslated(100, -100).thatsFilledWith(yellow),
shape6.withFlippedX.thatsRotated(-45).thatsFilledWith(green),
shape7.thatsRotated(-135).thatsTranslated(-70.71, 70.71).thatsFilledWith(Color(0, 228, 255)),
shape4.thatsRotated(-45).thatsTranslated(0, 141.42).thatsFilledWith(Color(255, 74, 0))
)
tangramDuck.thatsTranslated(-100,-250).draw
def tangramFish = picStack(
Picture {},
shape1.thatsRotated(135).thatsTranslated(141.42, 0).thatsFilledWith(red),
shape1.thatsRotated(-135).thatsTranslated(141.42, 0).thatsFilledWith(yellow),
shape3.thatsRotated(135).thatsTranslated(145, -35.35).thatsFilledWith(Color(0, 120, 22)),
shape5.withFlippedX.thatsRotated(45).thatsTranslated(145, 35).thatsFilledWith(purple),
shape4.thatsRotated(45).thatsTranslated(145, -105).thatsFilledWith(Color(255, 74, 0)),
shape6.withFlippedY.thatsRotated(225).thatsTranslated(290, -38).thatsFilledWith(green),
shape7.withFlippedX.thatsRotated(225).thatsTranslated(290, 100).thatsFilledWith(Color(0, 228, 255))
)
tangramFish.thatsTranslated(400, -250).draw
def tangramBird = picStack(
Picture {},
shape1.thatsRotated(135).thatsTranslated(141.42,-100).thatsFilledWith(red),
shape1.thatsRotated(90).thatsTranslated(40, -60).thatsFilledWith(yellow),
shape7.withFlippedX.thatsRotated(45).thatsTranslated(145, -100).thatsFilledWith(Color(0, 228, 255)),
shape4.thatsRotated(90).thatsTranslated(210, -23).thatsFilledWith(Color(255, 74, 0)),
shape3.thatsRotated(90).thatsTranslated(110, 80).thatsFilledWith(Color(0, 120, 22)),
shape6.withFlippedX.thatsTranslated(160, 130).thatsFilledWith(green),
shape5.thatsRotated(-135).thatsTranslated(160, 160).thatsFilledWith(purple)
)
tangramBird.thatsTranslated(500, 460).draw
def tangramChristmastree = picStack(
Picture {},
shape1.thatsRotated(-90).thatsFilledWith(red),
shape6.withFlippedY.thatsRotated(90).thatsTranslated(100, -100).thatsFilledWith(green),
shape5.thatsRotated(90).thatsTranslated(100, 0).thatsFilledWith(purple),
shape4.withFlippedY.thatsFilledWith(Color(255, 74, 0)),
shape1.thatsRotated(90).withFlippedY.thatsTranslated(50, 100).thatsFilledWith(yellow),
shape7.thatsRotated(45).withFlippedY.thatsTranslated(125, 100).thatsFilledWith(Color(0, 228, 255)),
shape3.thatsRotated(45).thatsTranslated(15, -100).thatsFilledWith(Color(0, 120, 22)),
)
tangramChristmastree.thatsTranslated(-700, 175).draw
def tangramDog = picStack(
Picture {},
shape1.withFlippedX.thatsRotated(45).thatsFilledWith(red),
shape1.thatsRotated(135).withFlippedX.thatsTranslated(-210, -70).thatsFilledWith(yellow),
shape5.thatsRotated(225).thatsTranslated(-71, -145).thatsFilledWith(purple),
shape3.thatsRotated(45).thatsTranslated(-210, -70).thatsFilledWith(Color(0, 120, 22)),
shape6.withFlippedX.thatsRotated(45).thatsTranslated(-210, 70).thatsFilledWith(green),
shape7.thatsRotated(45).withFlippedY.thatsTranslated(-210, 0).thatsFilledWith(Color(0, 228, 255)),
shape4.thatsRotated(45).thatsFilledWith(Color(255, 74, 0))
)
tangramDog.thatsTranslated(750, 140).draw
def tangramBoat = picStack(
Picture {},
shape1.thatsFilledWith(red),
shape1.thatsRotated(-90).withFlippedX.thatsFilledWith(yellow),
shape3.thatsRotated(45).thatsTranslated(110, -27).thatsFilledWith(Color(0, 120, 22)),
shape5.thatsRotated(-45).thatsTranslated(180, -25).thatsFilledWith(purple),
shape4.thatsRotated(135).thatsTranslated(250, -98).thatsFilledWith(Color(255, 74, 0)),
shape7.thatsRotated(45).thatsTranslated(110, -110).thatsFilledWith(Color(0, 228, 255)),
shape6.withFlippedX.thatsRotated(-45).thatsTranslated(110, -180).thatsFilledWith(green)
)
tangramBoat.thatsTranslated(-700, -200).draw
def tangramButterfly = picStack(
Picture {},
shape1.thatsRotated(-45).thatsTranslated(73, 72).thatsFilledWith(red),
shape1.thatsRotated(-45).withFlippedX.thatsTranslated(-74, 72).thatsFilledWith(yellow),
shape3.thatsRotated(45).thatsFilledWith(Color(0, 120, 22)),
shape5.thatsRotated(-45).thatsTranslated(71, 0).thatsFilledWith(purple),
shape4.thatsRotated(-45).thatsTranslated(0, -73).thatsFilledWith(Color(255, 74, 0)),
shape7.thatsRotated(135).thatsTranslated(-70, -4).thatsFilledWith(Color(0, 228, 255)),
shape6.withFlippedX.thatsRotated(45).thatsFilledWith(green)
)
tangramButterfly.thatsTranslated(100, 500).draw
def tangramTriangle = picStack(
Picture {},
shape1.withFlippedX.thatsFilledWith(red),
shape1.withFlippedX.thatsTranslated(0, 200).thatsFilledWith(yellow),
shape3.thatsTranslated(0, 100).thatsFilledWith(Color(0, 120, 22)),
shape5.thatsRotated(-90).thatsTranslated(53, 50).thatsFilledWith(purple),
shape4.thatsRotated(90).thatsTranslated(-47, 50).thatsFilledWith(Color(255, 74, 0)),
shape7.thatsTranslated(100, 100).thatsFilledWith(Color(0, 228, 255)),
shape6.withFlippedX.thatsTranslated(0, 100).thatsFilledWith(green)
)
tangramTriangle.thatsTranslated(-250, 0).draw
def tangramHeart = picStack(
Picture {},
shape1.thatsRotated(90).thatsFilledWith(red),
shape1.thatsRotated(-90).thatsTranslated(0, 200).thatsFilledWith(yellow),
shape3.thatsTranslated(100, 200).thatsFilledWith(Color(0, 120, 22)),
shape5.thatsTranslated(200, 100).thatsFilledWith(purple),
shape4.thatsRotated(-180).thatsTranslated(100, 0).thatsFilledWith(Color(255, 74, 0)),
shape7.thatsRotated(90).thatsTranslated(100,100).thatsFilledWith(Color(0, 228, 255)),
shape6.withFlippedX.thatsTranslated(150, 50).thatsFilledWith(green)
)
tangramHeart.thatsTranslated(-550, 400).draw
def tangramMountain = picStack(
Picture {},
shape1.thatsRotated(135).thatsFilledWith(red),
shape1.thatsRotated(45).thatsTranslated(148, 0).thatsFilledWith(yellow),
shape3.thatsTranslated(72, 172).thatsFilledWith(Color(0, 120, 22)),
shape5.withFlippedX.thatsRotated(45).thatsTranslated(0, 0).thatsFilledWith(purple),
shape4.thatsRotated(135).thatsTranslated(143, 0).thatsFilledWith(Color(255, 74, 0)),
shape7.thatsRotated(-45).thatsTranslated(145,0).thatsFilledWith(Color(0, 228, 255)),
shape6.withFlippedY.thatsRotated(45).thatsTranslated(0, 69).thatsFilledWith(green)
)
tangramMountain.thatsTranslated(50, 0).draw