Code Sketch


Muskan
By: Shardul Chavan
Category: Art
// Clear canvas and maximize speed
clear()
setBackgroundH(blue,white)
setSpeed(superFast)

val radius = 150.0
val navyBlue = Color(0, 0, 128)

// Step 1: Draw the tricolor circle perfectly line-by-line
var y = -radius
while (y <= radius) {
    // Calculate the horizontal width of the circle at this Y position
    val w = math.sqrt(radius * radius - y * y)
    
    // Assign colors based on the three equal vertical zones (-150 to 150)
    val c = if (y > 50) {
        Color(255, 153, 51)   // Saffron (Top)
    } else if (y >= -50) {
        Color(255, 255, 255) // White (Middle)
    } else {
        Color(19, 136, 8)    // Green (Bottom)
    }
    
    setPenColor(c)
    jumpTo(-w, y)
    lineTo(w, y)
    
    y += 0.5 // Small step ensures a perfectly smooth, solid fill
}

// Step 2: Draw the Ashoka Chakra directly in the center
val chakraRadius = 35
jumpTo(0, 0)
setPenColor(navyBlue)
setPenThickness(2)
                  
// Central hub dot
setFillColor(navyBlue)
circle(4)

// 24 Spokes
repeat(24) {
    forward(chakraRadius)
    back(chakraRadius)
    right(360.0 / 24)
}
setFillColor(noColor)
penUp()
hop(35)
left(90)
circle(35)


home()
hop(150)
left(90)
circle(150)
left(90)
hop(350)
left(180)
setPenColor(white)
setPenFontSize(30)
write("Happy Independence Day")