Code Sketch
Natural Scenery
Category: Art
// By Aditya Hasteer Sharma
cleari()
setSpeed(superFast)
setBackground( ColorMaker.hsl(215, 0.38, 0.64))
// the mountains part
def mountain(n: Double) = Picture.fromVertexShape { s =>
import s._
beginShape()
curveVertexRt(-250, 0)
curveVertexRt(-250, 0)
curveVertexRt(n, 100)
curveVertexRt(n, 0)
curveVertexRt(n, 0)
endShape()
}
def mountains(num: Int, size: Double): Picture = {
if (num == 1) {
mountain(size)
}
else {
fillColor(cm.green) * penColor(Color(44, 130, 51)) -> 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 sun = Picture {
setPenColor(yellow)
setFillColor(orange)
circle(70)
}
val scenery = picStack(
m,
trans(400, 200) -> birds(10, 50),
trans(200, 200) -> sun
)
draw(scenery)
setPosition(-150, -50)
hop(-300)
val a = trans(-300, -350) -> Picture {
setFillColor(ColorMaker.hsla(227, 0.90, 0.63, 0.80))
setPenColor(noColor)
repeat(2) {
forward(350)
right()
forward(1500)
right()
}
}
draw(a)
// Now the Trees part
def branch(size: Double): Picture = Picture {
forward(size)
}
def tree(n: Int, size: Double): Picture = {
if (n == 1) {
branch(size)
}
else {
picStack(
branch(size),
trans(0, size) * rot(30) -> tree(n - 1, size - 10),
trans(0, size) * rot(-30) -> tree(n - 1, size - 10),
)
}
}
val tpic1 = scale(0.2) * penColor(Color(12, 83, 12)) * penThickness(10) * trans(-200, 0) -> tree(10, 100)
val tpic2 = scale(0.2) * penColor(Color(12, 83, 12)) * penThickness(10) * trans(1200, 0) -> tree(10, 100)
val tpic3 = scale(0.2) * penColor(Color(12, 83, 12)) * penThickness(10) * trans(2700, 0) -> tree(10, 100)
val jaja = picStack(
scenery,
scenery
.withFading(300)
.withBlurring(20)
.withFlippedY
.withTranslation(0, 3),
tpic1,
tpic1
.withFading(300)
.withBlurring(20)
.withFlippedY
.withTranslation(0, 3),
tpic2,
tpic2
.withFading(300)
.withBlurring(20)
.withFlippedY
.withTranslation(0, 3),
tpic3,
tpic3
.withFading(300)
.withBlurring(20)
.withFlippedY
.withTranslation(0, 3)
)
draw(jaja)