Code Sketch
Concurrent Turtle Flowers
// Contributed by Maydha Kohli from Dallas, TX
clear()
setPenFontSize(40)
zoom(0.3, 0, 0)
val bluecolor= color(127,127,255)
val pinkcolor= color(255,51,153)
val tancolor=color(200,153,98)
val goldcolor=color(245,204,51)
val aquacolor=color(0,255,230)
val orangecolor= color(255,102,0)
val rocolor= color(255,102,102)
val pbcolor= color(122,122,255)
val blu2color= color(133,133,200)
val bpinkcolor= color(255,0,255)
val purplecolor= color(102,51,102)
//making the flowers
makeflower(pinkcolor,0,0,true,turtle0)
val t1= newTurtle(0,0)
makeflower(bluecolor,600,0,false,t1)
val t2= newTurtle(0,0)
makeflower(yellow,-600,0,false,t2)
val t3= newTurtle(0,0)
makeflower(red,0,700,false,t3)
val t4= newTurtle(0,0)
makeflower(purple,600,700,false,t4)
val t5= newTurtle(0,0)
makeflower(white,-600,700,false,t5)
val t6= newTurtle(0,0)
makeflower(tancolor,0,-700,false,t6)
val t7= newTurtle(0,0)
makeflower(goldcolor,600,-700,false,t7)
val t8= newTurtle(0,0)
makeflower(aquacolor,-600,-700,false,t8)
val t9= newTurtle(0,0)
makeflower(orangecolor,-1200,-700,false,t9)
val t10= newTurtle(0,0)
makeflower(rocolor,-1200,0,false,t10)
val t11= newTurtle(0,0)
makeflower(pbcolor,-1200,700,false,t11)
val t12= newTurtle(0,0)
makeflower(blu2color,1200,700,false,t12)
val t13= newTurtle(0,0)
makeflower(bpinkcolor,1200,0,false,t13)
val t14= newTurtle(0,0)
makeflower(purplecolor,1200,-700,false,t14)
def makeflower(p: Color, startx: Int, starty: Int, writetext: Boolean, t: Turtle) {
runInBackground(makeflowerWorker(p, startx, starty, writetext, t))
}
def makeflowerWorker(p: Color, startx: Int, starty: Int, writetext: Boolean, t: Turtle) {
t.setPenThickness(1)
t.setAnimationDelay(20)
t.setPenColor(blue)
//the center of the flower
t.setFillColor(orange)
t.setHeading(90)
t.setPosition(startx,starty)
repeat(6) {
t.forward(100)
t.right(60)
}
/*val score = MusicScore(
Melody("Xylophone", "C6q D#6q F6q G6q D#6q F6h Rq D#6q F6q G6q F6q C6q D#6h Rq"),
Rhythm("Hand_Clap", "q", "o.o.o.o.o.o.o.o.")
)
val t2=newTurtle(-1100,0)
t2.invisible
t2.playSound(score)
*/
//draw the petals
drawPetal(75+startx,100+starty,p,t)
drawPetal(0+startx,-100+starty,p,t)
drawPetal(100+startx,-30+starty,p,t)
drawPetal(-70+startx,100+starty,p,t)
drawPetal(-100+startx,-30+starty,p,t)
//code for the stem
t.setFillColor(white)
t.setPosition(0+startx,-100+starty)
t.setHeading(90)
t.right(180)
t.setPenColor(green)
t.setPenThickness(5)
repeat(300) {
t.left(0.1)
t.forward(1)
}
//code for the leaf
t.setPosition(0+startx,-200+starty)
t.setPenColor(green)
t.setFillColor(green)
t.setPenThickness(2)
t.right(100)
repeat(100) {
t.right(0.5)
t.forward(1)
}
t.right(100)
repeat(100) {
t.right(1)
t.forward(1)
}
//code for the word 'flower'
if(writetext) {
t.setPenColor(black)
t.setFillColor(white)
t.setPenThickness(4)
t.setPosition(0,300)
t.write(" FLOWERS")
t.setPosition(0,255)
t.write(" BY MAYDHA")
}
//this is the function to draw a petal
def drawPetal(x: Int, y: Int, c: Color, t: Turtle) {
t.setPosition(x,y)
t.setPenColor(black)
t.setFillColor(c)
repeat(10) {
t.forward(50)
t.right(36)
}
}
}//draw petal ends here