-
Notifications
You must be signed in to change notification settings - Fork 6
/
DrawCircles.elm
40 lines (30 loc) · 977 Bytes
/
DrawCircles.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
40
module DrawCircles where
import Array as A
import Color exposing (Color, blue, brown, green, orange, purple, red, yellow)
import Graphics.Collage exposing (Form, circle, collage, filled, move)
import Graphics.Element exposing (Element)
import List exposing (map)
import Maybe
color : Int -> Color
color n =
let colors =
A.fromList [ green, red, blue, yellow, brown, purple, orange ]
maybeColor = A.get (n % (A.length colors)) colors
in
Maybe.withDefault green maybeColor
circleForm : (Int, (Int, Int)) -> Form
circleForm (r, (x, y)) =
circle (toFloat r*5)
|> filled (color r)
|> move (toFloat x,toFloat y)
drawCircles : List (Int, (Int, Int)) -> (Int, Int) -> Element
drawCircles d (w, h) = collage w h <| map circleForm d
main =
drawCircles [
(3, (-200, 0)),
(4, (-100, 0)),
(5, (0, 0)),
(7, (100, 0)),
(9, (200, 0))
]
(600, 400)