Code Sketch
Sierpinski triangle
By: Aditya Pant
Category: Art
1


0




cleari() setSpeed(fast) right(30) def triangle(n: Int) { repeat(3) { forward(n) right(120) } } def shape(n: Int) { // savePosHe() setPenColor(noColor) setFillColor(cm.rgb(n.toInt, math.abs(255-n*3).toInt, 125)) triangle(n) if (n < 10) { triangle(n) } else { savePosHe() shape(n/2) hop(n/2) shape(n/2) hop(-n/2) right(60) hop(n/2) left(60) shape(n/2) restorePosHe() } // restorePosHe() } shape(300)





Your Comment:





Login to post a comment