Code Sketch
New-Design
cleari()
setBackground(white)
setSpeed(superFast)
setPenColor(gray.fadeOut(0.9))
setPenThickness(1)
def polygon(n: Int) {
var len = 30
if (n <= 4) {
len = len + 20
}
repeat(n) {
forward(len)
right(360.0 / n)
}
}
val nx = 15
val ny = 15
val cb = canvasBounds
val dx = cb.width / nx
val dy = cb.height / ny
def shape() {
savePosHe()
val a = random(-10, 10)
val r = random(3, 9)
right(a)
polygon(r)
restorePosHe()
}
def posx(gx: Int) = cb.x + gx * dx
def posy(gy: Int) = cb.y + gy * dy
def block(gx: Int, gy: Int) {
setPosition(posx(gx), posy(gy))
setFillColor(randomColor.fadeOut(0.9))
shape()
}
repeatFor(0 until nx) { x =>
repeatFor(0 until ny) { y =>
block(x, y)
}
}
val p1 = scale(0.14) -> Picture.image("C:/Users/Nitin/Pictures/p1.png")
drawCentered(p1)