Code Sketch


Tree Tangram
By: Saania Sayed
Category: Programming
cleari

showAxes()
showGrid()

def shape1 = Picture{
    right(135)
    forward(141.42)
    left(135)
    forward(200)
    left(135)
    forward(141.42)
}.thatsStrokeColored(red).withFillColor(red)

def shape2 = Picture{
    right(135)
    forward(141.42)
    left(135)
    forward(200)
    left(135)
    forward(141.42)
}.thatsStrokeColored(yellow).withFillColor(yellow)

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(green).withFillColor(green)

def shape4 = Picture{
    right()
    forward(100)
    left(135)
    forward(70.71)
    left(90)
    forward(70.71)   
}.thatsStrokeColored(red).withFillColor(red)

def shape5 = Picture{
    left(45)
    forward(70.71)
    left(135)
    forward(100)
    left(135)
    forward(70.71)
}.thatsStrokeColored(purple).withFillColor(purple)

def shape6 = Picture{
    forward(100)
    right(135)
    forward(70.71)
    right(45)
    forward(100)
    right(135)
    forward(70.71)
}.thatsStrokeColored(Color(0, 139, 0)).withFillColor(Color(0, 139, 0))

def shape7 = Picture {
    left(45)
    forward(141.42)
    left(135)
    forward(100)
    left(90)
    forward(100)
}.thatsStrokeColored(blue).withFillColor(blue)

def treeTangram = picStack(
    Picture{},
    shape4.withFlippedY.thatsTranslated(-50, 0).withFillColor(Color(255, 89, 16)),
    shape1.thatsRotated(-90).thatsTranslated(-50, 0).withFillColor(red),
    shape5.thatsRotated(90).thatsTranslated(50, 0).withFillColor(purple),
    shape6.thatsRotated(90).withFlippedY.thatsTranslated(100, -50).withFillColor(green),
    shape1.thatsRotated(90).withFlippedY.thatsTranslated(0, 100).withFillColor(yellow),
    shape7.thatsRotated(45).withFlippedY.thatsTranslated(70, 100).withFillColor(blue),
    shape3.thatsRotated(45).thatsTranslated(-35, -100).withFillColor(Color(0, 57, 22))
)

treeTangram.withPenColor(noColor).draw