-
Notifications
You must be signed in to change notification settings - Fork 6
/
EyesView.elm
39 lines (29 loc) · 966 Bytes
/
EyesView.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{-
This module contains functions which draw
the eyes.
-}
module EyesView where
import Color exposing (black, white)
import Graphics.Collage exposing (Form, collage, filled, group, move, moveX, oval)
import Graphics.Element exposing (Element)
eyeBorder : Float -> Float -> Form
eyeBorder w h =
group [
filled black <| oval w h,
filled white <| oval (w*9/10) (h*9/10)
]
eyePupil : Float -> Float -> Form
eyePupil w h = filled black <| oval w h
eyesView : (Int, Int) -> (Float, Float, Float, Float) -> Element
eyesView (w, h) (xPl, yPl, xPr, yPr) =
let xC = (toFloat w) / 4
yC = (toFloat h) / 2
in
collage w h [
eyeBorder (2*xC) (2*yC) |> moveX (-xC),
eyeBorder (2*xC) (2*yC) |> moveX xC,
eyePupil (xC/5) (yC/5) |> move (xPl,yPl),
eyePupil (xC/5) (yC/5) |> move (xPr,yPr)
]
-- test
main = eyesView (700, 500) (-50, -50, 100, 100)