-
Notifications
You must be signed in to change notification settings - Fork 0
/
Block.elm
43 lines (28 loc) · 797 Bytes
/
Block.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
41
42
43
module Block exposing (draw, Block, BlockSize, Location)
import Collage exposing (Form, filled, group, move, outlined, solid, square)
import Color exposing (Color)
type alias Block =
{ location : Location
, color : Color
}
type alias BlockSize =
Float
type alias Location =
( Float, Float )
paint : BlockSize -> Color -> Form
paint size color =
let
shape =
square size
content =
shape |> filled color
border =
shape |> outlined (solid Color.black)
in
group [ content, border ]
plot : BlockSize -> Location -> (Form -> Form)
plot size ( x, y ) =
move ( x * size, y * size )
draw : BlockSize -> Block -> Form
draw size { location, color } =
paint size color |> plot size location