Last active
August 29, 2015 14:24
-
-
Save vapidbabble/e7f7e9407e6fe5a632c2 to your computer and use it in GitHub Desktop.
Unicursal hexagram in Elm
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
| import Color exposing (..) | |
| import Graphics.Collage exposing (..) | |
| import Graphics.Element exposing (..) | |
| hexagon : Color -> Form | |
| hexagon clr = outlined (solid clr) (ngon 6 150) | |
| hex_on_a_point : Float -> Color -> Form | |
| hex_on_a_point deg clr = rotate (degrees deg) (hexagon clr) | |
| uni_path : Path | |
| uni_path = | |
| let radius = 150 | |
| angle = 30 | |
| radians= angle/180.0 * pi | |
| factor1 = cos radians | |
| factor2 = sin radians | |
| number = factor1 * radius | |
| half = factor2 * radius | |
| in | |
| path [ | |
| (0,radius), | |
| (-number,-half), | |
| (number,half), | |
| (0,-radius), | |
| (-number,half), | |
| (number,-half), | |
| (0,radius) | |
| ] | |
| unicursal : Color -> Form | |
| unicursal clr = outlined (solid clr) uni_path | |
| main : Element | |
| main = | |
| collage 300 300 | |
| [ filled black (circle 150) | |
| , hex_on_a_point 90 green | |
| , unicursal red | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment