Skip to content

Instantly share code, notes, and snippets.

@litan
Created September 12, 2017 13:20
Show Gist options
  • Save litan/977f31924921ea718fdb6d0fac7e6b49 to your computer and use it in GitHub Desktop.
Save litan/977f31924921ea718fdb6d0fac7e6b49 to your computer and use it in GitHub Desktop.
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