Code Sketch


sapirography design by shlok Thakur
By: Mhalsakant School
Category: Art
// --- Stunning Cosmic Geometric Wave Animation in Kojo ---

cleari()

var step = 0.0
val ringCount = 24

animateWithState(0.0) { angle =>
  erasePictures()

  // Deep Space Background
  setBackground(Color(8, 12, 24))

  // Twinkling Background Stars
  for (i <- 0 until 80) {
    val sx = (i * 41) % 500 - 250
    val sy = (i * 59) % 400 - 200
    val star = Picture.circle(if (i % 3 == 0) 2 else 1)
    star.setFillColor(if (i % 2 == 0) Color(255, 255, 255) else Color(100, 200, 255))
    star.setPenColor(noColor)
    star.setPosition(sx, sy)
    draw(star)
  }

  // Rotating Central Geometric Mandalas / Waves
  for (i <- 0 until ringCount) {
    val radius = 30.0 + i * 10.0
    val waveOffset = Math.sin(angle * 0.04 + i * 0.25) * 20.0
    val currentRadius = radius + waveOffset

    val x = Math.cos(Math.toRadians(angle * 1.5 + i * 15)) * (i * 3.0)
    val y = Math.sin(Math.toRadians(angle * 1.2 + i * 15)) * (i * 3.0)

    val shape = Picture.circle(currentRadius)
    shape.setFillColor(noColor)
    
    // Dynamic color shifting based on index and angle
    val redVal = ((i * 10 + angle) % 255).toInt
    val greenVal = ((i * 15 + angle * 0.5) % 255).toInt
    val blueVal = 255
    
    shape.setPenColor(Color(redVal, greenVal, blueVal))
    shape.setPenThickness(1.5)
    shape.setPosition(x, y)
    draw(shape)
  }

  // Pulsing Central Core
  val coreScale = 1.0 + Math.sin(angle * 0.1) * 0.2
  val core = Picture.circle(18 * coreScale)
  core.setFillColor(Color(255, 200, 50))
  core.setPenColor(Color(255, 255, 255))
  core.setPenThickness(2)
  core.setPosition(0, 0)
  draw(core)

  // Floating Particle Ring
  for (p <- 0 until 16) {
    val pAngle = Math.toRadians(p * 22.5 + angle * 2.0)
    val pDist = 140.0 + Math.sin(angle * 0.08 + p) * 15.0
    val px = Math.cos(pAngle) * pDist
    val py = Math.sin(pAngle) * pDist

    val particle = Picture.circle(4)
    particle.setFillColor(Color(0, 255, 200))
    particle.setPenColor(noColor)
    particle.setPosition(px, py)
    draw(particle)
  }

  step += 1.0
  (angle + 1.5) % 360.0
}