Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A tree with shapes
Shape.clear()
setBackgroundH(black, blue)
val (height, breadth) = (100, 20)
def stem = Shape.rectangle(breadth, height).outlined(lightGray).filled(lightGray)
def tree(n: Double): Shape = {
if (n == 0)
stem
else
// on2 places shapes on each other without centering
tree(n-1) .rotated(30) .scaled(0.7) .translated(0, height * 0.95) on2
tree(n-1) .rotated(-35) .scaled(0.65) .translated(0, height * 0.95) on2
stem
}
Shape.draw(tree(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment