aboutsummaryrefslogtreecommitdiff
path: root/colors.lua
blob: 846129c04c1831569b2a5440d1e268919ae2ae48 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
local dark_text_color = 0xD1CDD5
local light_text_color = 0x1D1D1D

local dark_or_light = "dark" -- dark / light

function build_color(bg, fg, text, warn, critic, bg_alpha, fg_alpha)
    return {
        bg       = bg,
        fg       = fg,
        text     = text,
        warn     = warn or 0xFF9000,
        critic   = critic or 0xFF0000,
        bg_alpha = bg_alpha or 0.2,
        fg_alpha = fg_alpha or 0.8,
    }
end

C = {
    blue = {
        dark  = build_color(0xA6A6A6, 0x5594FF, dark_text_color),
        light = build_color(0x252525, 0x151515, light_text_color),
    },
    deepblue = {
        dark  = build_color(0xA6A6A6, 0x0000a8, 0x55ffff, nil, nil, 0.1),
        light = build_color(0x180047, 0x00008B, 0x180047, nil, nil, 0.1),
    },
    green = {
        dark  = build_color(0xA6A6A6, 0x00ff00, dark_text_color),
        light = build_color(0x252525, 0x00ff00, light_text_color),
    },
    emerald = {
        dark  = build_color(0xD3FACD, 0x539950, 0xD3FACD, nil, nil, 0.1),
        light = build_color(0x8bff85, 0x3f753d, 0x1a3019, nil, nil, 0.1),
    },
    yellow = {
        dark  = build_color(0xA6A6A6, 0xfafa37, dark_text_color),
        light = build_color(0x252525, 0xfdff00, light_text_color),
    },
    purple = {
        dark  = build_color(0xA6A6A6, 0xbc00bc, dark_text_color),
        light = build_color(0x252525, 0x800080, light_text_color),
    },
    violet = {
        dark  = build_color(0xA6A6A6, 0x7028E5, dark_text_color),
        light = build_color(0x252525, 0x5329AE, light_text_color),
    },
    crimson = {
        dark  = build_color(0xA6A6A6, 0xdc143c, dark_text_color),
        light = build_color(0x252525, 0xd11339, light_text_color),
    },
    orange = {
        dark  = build_color(0xA6A6A6, 0xffa500, dark_text_color, 0xff4f00),
        light = build_color(0x252525, 0xffa500, light_text_color, 0xff4f00),
    },
    maroon = {
        dark  = build_color(0xA6A6A6, 0xae0000, dark_text_color),
        light = build_color(0x252525, 0x940000, light_text_color),
    },
    pink = {
        dark  = build_color(0xffccdd, 0xff3377, 0xffccdd),
        light = build_color(0xffccdd, 0xff3377, 0xff0055),
    },
    cyan = {
        dark  = build_color(0xA6A6A6, 0x48FFE7, dark_text_color),
        light = build_color(0x252525, 0x00C9AF, light_text_color),
    },
    aquamarine = {
        dark  = build_color(0xA6A6A6, 0x76EDC3, dark_text_color),
        light = build_color(0x252525, 0x64C8A5, light_text_color),
    },
    monochrome = {
        dark  = build_color(0x484848, 0xDEDEDE, 0xDEDEDE, 0xFF0000, 0xDEDEDE),
        light = build_color(0x252525, 0x151515, 0x151515, 0xFF0000, 0x1D1D1D)
    },
    gruvbox = {
        dark  = build_color(0x282828, 0xEBDBB2, 0xFBF1C7, 0xFE8019, 0xCC241D),
        light = build_color(0xFBF1C7, 0x3C3836, 0x282828, 0xD65D0E, 0xCC241D),
    },
    contrast = {
        dark  = build_color(0x000000, 0xffffff, 0xffffff, 0xf36910, 0xFF0000, 0.5, 1),
        light = build_color(0xffffff, 0x000000, 0x000000, 0xf36910, 0xFF0000, 0.3, 1)
    },
}



function choose_random_theme()
    dark_themes = dark_themes or {}
    light_themes = dark_themes or {}

    if #dark_themes == 0 and #light_themes == 0 then
        for _, v in pairs(C) do
            for kk, vv in pairs(v) do
                if kk == "dark" then
                    dark_themes[#dark_themes + 1] = vv
                elseif kk == "light" then
                    light_themes[#dark_themes + 1] = vv
                end
            end
        end
    end

    if dark_or_light == "dark" then
        return dark_themes[math.random(#dark_themes)]
    end

    return light_themes[math.random(#light_themes)]
end


function get_color_table(theme)
    if type(theme) ~= "string" then
        io.stderr:write("No theme provided. Defaulting to blue dark")
        return C.blue.dark
    end

    theme = string.lower(theme)

    if string.find(theme, "light") then
        dark_or_light = "light"
    else
        dark_or_light = "dark"
    end

    if theme == "monochrome dark" then
        return C.monochrome.dark
    elseif theme == "monochrome light" then
        return C.monochrome.light
    elseif theme == "blue dark" then
        return C.blue.dark
    elseif theme == "blue light" then
        return C.blue.light
    elseif theme == "deepblue dark" then
        return C.deepblue.dark
    elseif theme == "deepblue light" then
        return C.deepblue.light
    elseif theme == "green dark" then
        return C.green.dark
    elseif theme == "green light" then
        return C.green.light
    elseif theme == "emerald dark" then
        return C.emerald.dark
    elseif theme == "emerald light" then
        return C.emerald.light
    elseif theme == "yellow dark" then
        return C.yellow.dark
    elseif theme == "yellow light" then
        return C.yellow.light
    elseif theme == "purple dark" then
        return C.purple.dark
    elseif theme == "purple light" then
        return C.purple.light
    elseif theme == "violet dark" then
        return C.violet.dark
    elseif theme == "violet light" then
        return C.violet.light
    elseif theme == "crimson dark" then
        return C.crimson.dark
    elseif theme == "crimson light" then
        return C.crimson.light
    elseif theme == "orange dark" then
        return C.orange.dark
    elseif theme == "orange light" then
        return C.orange.light
    elseif theme == "maroon dark" then
        return C.maroon.dark
    elseif theme == "maroon light" then
        return C.maroon.light
    elseif theme == "pink dark" then
        return C.pink.dark
    elseif theme == "pink light" then
        return C.pink.light
    elseif theme == "cyan dark" then
        return C.cyan.dark
    elseif theme == "cyan light" then
        return C.cyan.light
    elseif theme == "aquamarine dark" then
        return C.aquamarine.dark
    elseif theme == "aquamarine light" then
        return C.aquamarine.light
    elseif theme == "gruvbox dark" then
        return C.gruvbox.dark
    elseif theme == "gruvbox light" then
        return C.gruvbox.light
    elseif theme == "contrast dark" then
        return C.contrast.dark
    elseif theme == "contrast light" then
        return C.contrast.light
    else
        io.stderr:write("ERROR. the provided theme does not exist. Defaulting to 'blue dark")
        return C.blue.dark
    end
end