Code Sketch


prerna
By: Mhalsakant School
Category: Art
var initPosRedY = 400.toDouble
var initPosGreenY = -400.toDouble
var initPosChakra = -500.toDouble

val saffron = Color(255, 153, 51)
val white = Color(255, 255, 255)
val green = Color(19, 136, 8)

val chakra = Picture {
    repeat(24) {
        repeat(3) {
            forward(50)
            right(120)
        }
        right(360 / 24)
    }
}
    .withPenColor(Color(0, 35, 145))
    .withPosition(0, 40)

val redRect = Picture.rect(80, 400)
    .withTranslation(-200, initPosRedY)
    .withFillColor(saffron)
    .withPenColor(saffron)

val greenRect = Picture.rect(80, 400)
    .withTranslation(-200, initPosGreenY)
    .withFillColor(green)
    .withPenColor(green)

val allPic = picStack(greenRect, redRect, chakra)
    .withScaling(1.2)

cleari
draw(allPic)
animate {
    chakra.rotate(-1)
}

animate {
    redRect.translate(0, -0.5)
    initPosRedY = initPosRedY - 0.5
    if (initPosRedY <= 100) {
        stopAnimation()
    }
}

animate {
    greenRect.translate(0, 0.5)
    initPosGreenY = initPosGreenY + 0.5
    if (initPosGreenY >= 100) {
        stopAnimation()
    }
}