// Example from http://lalitpant.blogspot.in/2012/05/recursive-drawing-with-kojo.html // we start with a square val size = 100 def Square = Picture { repeat (4) { forward(size) right() // default 90° } } // a stem is a distorted square filled in black def stem = scale(0.13, 1) * penColor(noColor) * fillColor(black) -> Square def drawing(n: Int): Picture = { if (n < 2) stem else GPics(stem, trans(0, size+10) * brit(0.1) -> GPics( rot(-25) * scale(0.72) -> drawing(n-1), rot( 50) * scale(0.55) -> drawing(n-1) ) ) } clear() setBackground(Color(255, 170, 29)) invisible() val pic = trans(0, -300) -> drawing(10) draw(pic)