Code Sketch


KALYANI KASHINATH PAWAR
By: Mhalsakant School
Category: Art
cleari()
setBackground(black)

// Define a basic square box face
def boxFace = Picture {
  setPenColor(cyan)
  setPenThickness(2)
  setFillColor(Color(0, 150, 255, 100)) // Translucent fill
  repeat(4) {
    forward(120)
    right(90)
  }
}

// Combine shapes to create a pseudo-3D layered cube structure
def box3D = picStack(
  boxFace.thatsTranslated(-30, -30),
  boxFace.thatsTranslated(30, 30),
  boxFace.thatsRotated(45).thatsScaled(0.7)
)

draw(box3D)

// Animate the box rotation and pulsing scale
var scaleFactor = 1.0
var growing = true

animate {
  box3D.rotate(1.5)
  
  if (growing) {
    scaleFactor += 0.005
    box3D.scale(1.005)
    if (scaleFactor >= 1.2) growing = false
  } else {
    scaleFactor -= 0.005
    box3D.scale(0.995)
    if (scaleFactor <= 0.8) growing = true
  }
}