Created
September 12, 2017 13:20
-
-
Save litan/977f31924921ea718fdb6d0fac7e6b49 to your computer and use it in GitHub Desktop.
A tree with shapes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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