Last active
August 29, 2015 14:07
-
-
Save gmp26/e9b9ca81ef71afca2968 to your computer and use it in GitHub Desktop.
arithmagons unmasked 3
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)) | |
] | |
|> collage w h | |
lineStyle = solid black | |
vertex : Float -> Form | |
vertex radius = | |
let d = ceiling <| radius*2 | |
in collage d d [ circle radius |> filled red | |
, circle radius |> outlined (solid black) | |
, inputField 40 40 |> toForm | |
] | |
|> toForm | |
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