Code Sketch


tangram dog
By: Mayur Manohar Dalvi
Category: Art
cleari

//showAxes()
//showGrid()


tangram.draw

def tangram = picStack(
    Picture {},
//    
   triangle1.thatsFilledWith(green).thatsRotated(135).thatsTranslated(70.71*3, -70.71),
    triangle1.thatsFilledWith(cm.gray).thatsRotated(30).thatsTranslated(+214, 142/2),
    triangle2.thatsFilledWith(blue).thatsRotated(45).thatsTranslated(0, 0),
    triangle2.thatsFilledWith(pink).thatsRotated(-135).thatsTranslated(142*1.5, 142/2),
//    triangle3.thatsFilledWith(cm.gray),
   parallelogram.thatsFilledWith(brown).thatsRotated(-45).thatsTranslated(0,42+100).withFlippedX,
   triangle4.thatsFilledWith(orange).thatsRotated(45).thatsTranslated(0,-70.71).withFlippedY,
   square.thatsFilledWith(red).thatsRotated(-45).thatsTranslated(70.71*2/2,0),
)



def square = 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 triangle1 = Picture{
    right()
    forward(100)
    left(135)
    forward(70.71)
    left(90)
    forward(70.71)   
}.thatsStrokeColored(black)

def triangle2 = Picture{
    right(135)
    forward(141.42)
    left(135)
    forward(200)
    left(135)
    forward(141.42)
}.thatsStrokeColored(black)

def triangle3 = Picture{
    left(45)
    forward(70.71)
    left(135)
    forward(100)
    left(135)
    forward(70.71)
}.thatsStrokeColored(black)

def parallelogram = Picture{
    forward(100)
    right(135)
    forward(70.71)
    right(45)
    forward(100)
    right(135)
    forward(70.71)
}.thatsStrokeColored(black)

def triangle4 = Picture {
    left(45)
    forward(141.42)
    left(135)
    forward(100)
    left(90)
    forward(100)
}.thatsStrokeColored(black)