Code Sketch


Flower Pattern With Squares
By: Anay Narendra Kamat
cleari

def range() = for {
    value <- 0 to 23
} yield (value, value % 2)


def square = Picture {
    setPenThickness(1)
    repeat(4) {
        forward(100)
        right
    }
}

repeatFor(range()) {
    case (counter, 1) =>
        val scale = 1.0 + counter / 10.0
        square
            .thatsTranslated(-50, -50)
            .thatsRotated(2*counter)
            .thatsStrokeSized(1/scale)
            .thatsScaled(scale).draw
    case (counter, 0) =>
        val scale = 1.0 + counter / 10.0
        square
            .thatsTranslated(-50, -50)
            .thatsRotated(0 - 2*counter)
            .thatsStrokeSized(1/scale)
            .thatsScaled(scale).draw            
}