/
Image.elm
103 lines (86 loc) · 2.84 KB
/
Image.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
module Image exposing (Image, bars, recurse, view, viewColor)
import Array exposing (Array)
import Color.Transparent as Color exposing (Color)
import Css
import Grid exposing (Grid)
import Html.Styled as Html exposing (Attribute, Html)
import Html.Styled.Attributes as Attrs exposing (css, style)
import Palette.Tango as Tango
import Set
type alias Image =
Grid Color
viewColor : List (Attribute msg) -> Color -> Html msg
viewColor attrs color =
Html.td
([ style "background-color" (Color.toRGBAString color)
, Attrs.width 10
, Attrs.height 10
]
++ attrs
)
[]
view : List (Attribute msg) -> Image -> Html msg
view attrs image =
Grid.view (viewColor attrs) image
recurse : Image
recurse =
let
-- Transparent
t =
Color.fromRGBA { red = 255, green = 255, blue = 255, alpha = Color.transparent }
-- White
w =
Color.fromRGBA { red = 255, green = 255, blue = 255, alpha = Color.opaque }
-- Green
g =
Color.fromRGBA { red = 62, green = 192, blue = 108, alpha = Color.opaque }
-- Key (black)
k =
Color.fromRGBA { red = 43, green = 45, blue = 45, alpha = Color.opaque }
in
case
Grid.fromRowsAndColumns
[ List.repeat 14 t
, [ t, k, k, k, k, k, k, k, k, k, k, k, k, t ]
, [ t, k, w, w, w, w, w, w, w, w, w, w, k, t ]
, [ t, k, w, k, k, k, k, k, k, k, k, w, k, t ]
, [ t, k, w, g, k, g, k, g, k, k, k, w, k, t ]
, [ t, k, w, k, k, k, k, k, k, k, k, w, k, t ]
, [ t, k, w, k, g, g, k, g, g, k, k, w, k, t ]
, [ t, k, w, k, k, k, k, k, k, k, k, w, k, t ]
, [ t, k, w, k, k, k, k, k, k, k, k, w, k, t ]
, [ t, k, w, w, w, w, w, w, w, w, w, w, k, t ]
, [ t, k, k, k, k, k, k, k, k, k, k, k, k, t ]
, [ t, t, t, t, t, k, k, k, k, t, t, t, t, t ]
, [ t, t, k, k, k, k, k, k, k, k, k, k, t, t ]
, [ t, k, k, k, w, k, w, k, w, k, w, k, k, t ]
, [ t, k, k, w, k, w, k, w, k, w, k, k, k, t ]
, [ t, k, k, k, k, k, k, k, k, k, k, k, k, t ]
, List.repeat 14 t
]
of
Ok grid ->
grid
Err problem ->
Debug.todo (Debug.toString problem)
bars : Image
bars =
let
b =
Color.fromColor Color.opaque Tango.skyBlue1
k =
Color.fromRGBA { red = 45, green = 45, blue = 45, alpha = Color.opaque }
in
case
Grid.fromRowsAndColumns
[ [ k, b, k, k ]
, [ b, b, b, b ]
, [ k, b, k, k ]
, [ k, b, k, k ]
, [ k, b, k, k ]
]
of
Ok grid ->
grid
Err problem ->
Debug.todo (Debug.toString problem)