/
Image.elm
131 lines (110 loc) · 3.52 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
module Image exposing (Image, bars, recurse, view, viewColor, waves)
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, k ]
, [ b, b, b, b, b ]
, [ k, b, k, k, k ]
, [ k, b, k, k, k ]
, [ k, b, k, k, k ]
]
of
Ok grid ->
grid
Err problem ->
Debug.todo (Debug.toString problem)
waves : Image
waves =
let
l =
Color.fromColor Color.opaque Tango.skyBlue1
d =
Color.fromColor Color.opaque Tango.skyBlue3
in
case
Grid.fromRowsAndColumns
[ [ d, d, d, d, d, d, d, l ]
, [ l, d, d, d, d, d, d, d ]
, [ d, l, l, l, d, d, d, d ]
, [ d, d, d, d, l, l, d, d ]
, [ d, d, d, d, d, d, l, l ]
, [ l, l, l, d, d, d, d, d ]
, [ d, d, d, l, l, d, d, d ]
, [ d, d, d, d, d, l, l, d ]
]
of
Ok grid ->
grid
Err problem ->
Debug.todo (Debug.toString problem)