Code Sketch


Tangram of Animals
By: Maya Anay Kamat
Category: Art
cleari

//showAxes()
//showGrid()
def darkGreen = Color(0, 84, 33)
def skyBlue = Color(0, 218, 221, 201)
def grassGreen=Color(0, 166, 37)
def lightBrown=Color(180, 123, 80)
def rhinoCol=Color(178, 158, 8)
def pigCol=Color(137, 122, 2)
def kangarooCol=Color(145, 64, 25)
def dinoCol=Color(244, 203, 121)
def lionCol=Color(145, 108, 0)
def ratCol=Color(97, 61, 0)



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).thatsFilledWith(darkGreen)

def shape4 = Picture {
    right()
    forward(100)
    left(135)
    forward(70.71)
    left(90)
    forward(70.71)
}.thatsStrokeColored(black).thatsFilledWith(orange)

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

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

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

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

def camelText= Picture{
    setPenFontSize(40)
    write("The Camel")
}

def grassHopperText= Picture{
    setPenFontSize(40)
    write("The GrassHopper")
}
def rabbitText= Picture{
    setPenFontSize(40)
    write("The Rabbit")
}
def rhinoText= Picture{
    setPenFontSize(40)
    write("The Rhino")
}
def pigText= Picture{
    setPenFontSize(40)
    write("The Pig")
}
def   kangarooText= Picture{
    setPenFontSize(40)
    write("The Kangaroo")
}
def dinoText= Picture{
    setPenFontSize(40)
    write("The Dinosaur")
}
def lionText= Picture{
    setPenFontSize(40)
    write("The Lion")
}
def ratText= Picture{
    setPenFontSize(40)
    write("The Rat")
}
def mainText= Picture{
    setPenColor(blue)
    setPenFont(Font("Cambria", 30))
    write("Tangram of Animals")
}

def camel = picStack(
    Picture {},
    camelText.thatsTranslated(-150, -200),
    shape3.thatsTranslated(0, 50),
    shape1.thatsTranslated(-50, -100),
    shape5.thatsTranslated(100, 50),
    shape4.withFlippedY.thatsTranslated(50, 100),
    shape6.withFlippedX.thatsTranslated(100, -50),
    shape1.thatsRotated(-45).thatsTranslated(-50+(-(141.42-50)),-50),
    shape7.thatsRotated(45).withFlippedY.thatsTranslated(70.71, 0).thatsTranslated(-70.71, -50)
    ).thatsFilledWith(darkGreen) 


def grassHopper = picStack(
    Picture {},
    grassHopperText.thatsTranslated(8, -160),
    shape1.thatsRotated(-90),
    shape1.thatsRotated(-90).withFlippedY.thatsTranslated(150, -150),
    shape4.thatsTranslated(0, -150).thatsTranslated(50, 0),
    shape7.thatsRotated(-135).thatsTranslated(-70.71, -(70.71+50)).thatsTranslated(250, 0),
    shape5.thatsRotated(-90).thatsTranslated(300, -(50+50)),
    shape3.thatsTranslated(0, -50).thatsTranslated(350, 0),
    shape6.withFlippedY.thatsRotated(90).thatsTranslated(400, -100)
 ) .thatsFilledWith(grassGreen) 


def rabbit = picStack(
    Picture {},
    rabbitText.thatsTranslated(-100, -150),
    shape1.thatsRotated(-90).thatsTranslated(0, 100),
    shape1.thatsRotated(-45).thatsTranslated(-100, 0),
    shape3.thatsTranslated(0, 50).thatsTranslated(50, 100),
    shape6.thatsRotated(45).thatsTranslated(100, 100),
    shape7.thatsRotated(-135).thatsTranslated(-100, -141.42),
    shape4.withFlippedY.thatsTranslated(-200, -141.42),
    shape5.thatsRotated(-45).withFlippedX.thatsRotated(-45).thatsTranslated(-50,-50).thatsTranslated((141.42-100),0)
   ).thatsFilledWith(lightBrown)

def rhino = picStack(
    Picture {},
    rhinoText.thatsTranslated(-52, -170),
    shape1.thatsRotated(-90),
    shape1.thatsRotated(90).thatsTranslated(100, -100),
    shape6.thatsRotated(-45).thatsTranslated(100, -100),
    shape4.thatsTranslated(100,-(100+70.71)),
    shape3.thatsRotated(45).thatsTranslated(-100, -100),
    shape7.thatsRotated(-45).thatsTranslated(100+70.71+70.71,-(100)),
    shape4.thatsRotated(-90).thatsTranslated(100+70.71+70.71, 0)
    
    ).thatsFilledWith(rhinoCol) 



def pig = picStack (
    Picture{},
   pigText.thatsTranslated(-29, -80),
   shape1.thatsRotated(45).withFlippedX,
   shape7.thatsTranslated(100, 0),
   shape1.thatsRotated(90).thatsTranslated(100, 0),
   shape3.thatsTranslated(200, 100),
   shape6.withFlippedX.thatsTranslated(0, -50).thatsTranslated(250, 0),
   shape4.thatsRotated(45).thatsTranslated(0, -70.71)
    ).thatsFilledWith(pigCol)


def kangaroo = picStack (
    Picture {},
    kangarooText.thatsTranslated(50, -210),
    shape1.thatsRotated(45),
    shape5.thatsRotated(-45).thatsTranslated(0, (141.42-(70.71/2))),
    shape4.thatsRotated(90).thatsTranslated(0, -50),
    shape1.thatsRotated(-135).thatsTranslated(141.42, 0),
    shape3.withFlippedY.thatsTranslated(-50, -50).thatsTranslated(141.42, -141.42),
    shape7.thatsRotated(-135).thatsTranslated(70.71, -(141.42+70.71)),
    shape6.thatsRotated(-90).withFlippedX.thatsTranslated(50, 50).thatsTranslated(141.42+70.71, -(141.42+70.71))
    ).thatsFilledWith(kangarooCol)


def dino = picStack(
    Picture {},
    dinoText.thatsTranslated(-190, -300),
    shape7.thatsTranslated(100, 0),
    shape6.withFlippedX,
    shape1.thatsTranslated(-100, -100),
    shape1.thatsTranslated(-200, -200),
    shape5.thatsTranslated(-50, -150),
    shape3.thatsTranslated(-50, -150),
    shape4.thatsRotated(90).thatsTranslated(0,-300)
    ).thatsFilledWith(dinoCol)
 

     
def lion = picStack (
    Picture {},
    lionText.thatsTranslated(-65, -70),
    shape1.thatsRotated(45),
    shape1.thatsRotated(-45).withFlippedX.thatsTranslated(0, 141.42),
    shape7.thatsTranslated(-(141.42-100), 141.42-100),
    shape6.withFlippedX.thatsTranslated(141.42+50, 50),
    shape3.thatsRotated(45).thatsTranslated(70.71, 0),
    shape5.thatsRotated(-45).thatsTranslated(70.71, -70.71),
    shape4.thatsRotated(-90).thatsTranslated((-50/2),50/2)
    
    ).thatsFilledWith(lionCol)

  def rat = picStack (
    Picture {},
    ratText.thatsTranslated(-30, -120),
    shape5.thatsRotated(-45),
    shape3.thatsRotated(-45),
    shape6.thatsRotated(-90).withFlippedX.thatsTranslated((100-70.71), -70.71),
    shape1.thatsRotated(-45).thatsTranslated(0, 70.71),
    shape1.thatsRotated(45).withFlippedX.thatsTranslated(141.42, -70.71),
    shape4.thatsRotated(45).withFlippedY.thatsTranslated(141.42, 0),
    shape7.thatsTranslated(141.42+100, 0)
    ).thatsFilledWith(ratCol)
  


def poster = picStack(
   Picture{},
    camel.thatsScaled(0.4).thatsTranslated(-200, 185),
    grassHopper.thatsScaled(0.4).thatsTranslated(-200+140, 210),
    rabbit.thatsScaled(0.4).thatsTranslated(-200+180+250, 180),
    rhino.thatsScaled(0.4).thatsTranslated(-226, 45),
    pig.thatsScaled(0.4).thatsTranslated(-39, 8),
    kangaroo.thatsScaled(0.4).thatsTranslated(189,26),
    dino.thatsScaled(0.4).thatsTranslated(-210, -108),
    lion.thatsScaled(0.4).thatsTranslated(-18,-160),
    rat.thatsScaled(0.4).thatsTranslated(185,-133),
    mainText.thatsTranslated(-121, 252)
    )
    
poster.draw