Code Sketch


Rangoli
By: Lalit Pant [2]
Category: Art
def border(t: Turtle, a: Double) {
    t.setAnimationDelay(200)
    t.setPenColor(black)
    t.right()
    t.forward(1200)
    repeat(15){
        t.setFillColor(red)
        t.turn(a)
        t.forward(40)
        t.turn(a)
        t.forward(40)
        t.turn(a)

        t.setFillColor(blue)
        t.turn(a)
        t.forward(40)
        t.turn(a)
        t.forward(40)
        t.turn(a)
    }
}

def flower(tt:Turtle, c:Color) {
    tt.setAnimationDelay(400)
    tt.setPenColor(black)
    tt.setFillColor(c)
    repeat(4){
        tt.right()
        repeat(90){
            tt.turn(-2)
            tt.forward(2)
        }
    }
}

clear()

val t1=newTurtle(-600,-150)
val t2=newTurtle(-600, 150)

border(t1,120)
border(t2,-120)


jumpTo(-50,100)
setAnimationDelay(20)
setPenColor(black)
setFillColor(green)
repeat(6){
    turn(-120)
    repeat(90){
        turn(-2)
        forward(2)
    }
}

val t3=newTurtle(-300,100)
val t4=newTurtle(-400,0)
val t5=newTurtle(-500,100)
val t6=newTurtle(-600,0)

val t7=newTurtle(200,100)
val t8=newTurtle(300,0)
val t9=newTurtle(400,100)
val t10=newTurtle(500,0)

flower(t3, orange)
flower(t4, yellow)
flower(t5, red)
flower(t6, purple)

flower(t7, orange)
flower(t8, yellow)
flower(t9, red)
flower(t10, purple)

turtle0.invisible()
t1.invisible()
t2.invisible()
t3.invisible()
t4.invisible()
t5.invisible()
t6.invisible()
t7.invisible()
t8.invisible()
t9.invisible()
t10.invisible()