Code Sketch
Mountains With Birds
By: Aditya Hasteer Sharma
2


0




// By Aditya Hasteer Sharma cleari() setSpeed(superFast) setBackground(cm.white) // the mountains part def mountain(n : Double) = Picture.fromVertexShape { s => import s._ beginShape() curveVertexRt(n, 0) curveVertexRt(n, 0) curveVertexRt(n, 90) curveVertexRt(n, 180) curveVertexRt(n, 180) endShape() } def mountains(num : Int, size : Double): Picture = { if(num == 1) { mountain(size) } else { fillColor(cm.brown) * penColor(noColor) -> picStack( mountain(size), trans(size * 1.9, 0) -> mountains(num -1, size) ) } } val m = mountains(3, 150) setPosition(800, 480) // Now the birds part def bird(n: Double) = penColor(black) * scale(1) -> Picture { right(90) right(60, n) left(120) right(60, n) } def birds(num: Int, Size: Double): Picture = { if (num == 1) { bird(Size) } else { picStack( bird(Size), trans(Size * 1.1, Size * 0.7) -> birds(num - 1, Size * 0.9) ) } } val scenery = picStack( m, trans(400, 200) -> birds(10, 50) ) draw(scenery, m)





Your Comment:





Login to post a comment