Code Sketch
Mountain Scenery
By: Aditya Hasteer Sharma
Category: Art
2


0




// By Aditya Hasteer Sharma cleari() setSpeed(superFast) //showGrid() //showAxes() setBackground(cm.white) setBackground(Color(50, 158, 255)) // 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) setPosition(-150, -50) setFillColor(cm.green) setPenColor(noColor) repeat(2) { forward(50) right() forward(870) right() } setPosition(220, 200) setPenColor(yellow) setFillColor(orange) circle(70)





Your Comment:





Login to post a comment