Created
October 14, 2014 11:34
-
-
Save gmp26/8ea17c0864c010487926 to your computer and use it in GitHub Desktop.
arithmagons editable
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
import Graphics.Input (Input, input) | |
import Graphics.Input.Field as Field | |
import Text | |
content : Input Field.Content | |
content = input Field.noContent | |
tf = toFloat | |
render : State -> (Int,Int) -> Element | |
render state (w,h) = | |
let rGon = 2*(tf w) / 5 | |
rVert = (tf w) / 10 | |
in [ngon 3 rGon | |
|> outlined {lineStyle | width <- 3} | |
|> rotate (-pi/6) | |
, vertex rVert |> move (rGon*cos (-pi/6), rGon*sin (-pi/6)) | |
, vertex rVert |> move (rGon*cos (pi/2), rGon*sin (pi/2)) | |
, vertex rVert |> move (rGon*cos (7*pi/6), rGon*sin (7*pi/6)) | |
, toForm (inputField 40 40) |> move (rGon*cos (-pi/6), rGon*sin (-pi/6)) | |
, toForm (inputField 40 40) |> move (rGon*cos (pi/2), rGon*sin (pi/2)) | |
, toForm (inputField 40 40) |> move (rGon*cos (7*pi/6), rGon*sin (7*pi/6)) | |
] | |
|> collage w h | |
lineStyle = solid black | |
vertex : Float -> Form | |
vertex radius = | |
[ circle radius | |
|> filled red | |
, circle radius | |
|> outlined (solid black) | |
] | |
|> group | |
inputField w h = width w <| height h <| (Field.field fieldStyle content.handle identity "Type here!" Field.noContent) | |
type State = {} | |
state = {} | |
ds = Field.defaultStyle | |
fieldStyle = { ds | outline <- | |
{ color = red | |
, width = Field.uniformly 1 | |
, radius = 5 | |
} | |
, style <- | |
{ typeface = [ "Times New Roman", "serif" ] | |
, height = Just 20 | |
, color = blue | |
, bold = False | |
, italic = False | |
, line = Nothing | |
} | |
} | |
main : Element | |
main = render state (400,400) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment