Last active
August 29, 2015 14:19
-
-
Save adusak/c8bc98a77a0fa01231d9 to your computer and use it in GitHub Desktop.
Diamond
This file contains hidden or 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
| from math import pi | |
| from python.common.Turtle import Turtle | |
| def diamond(radius=200): | |
| density = round(radius / 100 * 12) | |
| t = Turtle() | |
| length = (pi * radius) / density | |
| angle = (density - 2) * 180. / density | |
| k = density + 6 | |
| for _ in range(k): | |
| for i in range(density): | |
| t.forward(length) | |
| t.right(180 - angle) | |
| t.right(360. / k) | |
| t.export("diamond") | |
| diamond(600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment