Skip to content

Commit dec9498

Browse files
committed
Color coding changed from Love 0.10 to Love 0.11 format (255->1)
1 parent f04ed7c commit dec9498

File tree

10 files changed

+75
-73
lines changed

10 files changed

+75
-73
lines changed

conf.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function love.conf(t)
22
t.identity = nil -- The name of the save directory (string)
3-
t.version = "0.10.2" -- The LÖVE version this game was made for (string)
3+
t.version = "0.11.0" -- The LÖVE version this game was made for (string)
44
t.console = false -- Attach a console (boolean, Windows only)
55
t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean)
6-
t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean)
6+
t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean)
77
t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)
8-
8+
99
t.window.title = "GOOi demo" -- The window title (string)
1010
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
1111
t.window.width = 800 -- The window width (number)
@@ -22,7 +22,7 @@ function love.conf(t)
2222
t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean)
2323
t.window.x = nil -- The x-coordinate of the window's position in the specified display (number)
2424
t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)
25-
25+
2626
t.modules.audio = true -- Enable the audio module (boolean)
2727
t.modules.event = true -- Enable the event module (boolean)
2828
t.modules.graphics = true -- Enable the graphics module (boolean)

gooi/button.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ function gooi.newButton(params)
7070
if t:len() == 0 then
7171
xImg = math.floor(self.x + self.w / 2)
7272
end
73-
love.graphics.setColor(255, 255, 255)
74-
if not self.enabled then love.graphics.setColor(63, 63, 63) end
73+
love.graphics.setColor(1, 1, 1)
74+
if not self.enabled then love.graphics.setColor(1/4, 1/4, 1/4) end
7575
love.graphics.draw(self.icon, xImg, math.floor(self.y + self.h / 2), 0, 1, 1,
7676
math.floor(self.icon:getWidth() / 2),
7777
math.floor(self.icon:getHeight() / 2))

gooi/component.lua

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
component = {}
44
component.__index = component
55
component.colors = {
6-
blue = {2, 117, 216, 255},
7-
green = {92, 184, 92, 255},
8-
cyan = {91, 192, 222, 255},
9-
orange = {240, 173, 78, 255},
10-
red = {217, 83, 79, 255},
11-
black = {0, 0, 0, 255},
12-
white = {255, 255, 255, 255},
13-
clearGray = {247, 247, 247, 255},
14-
darkGray = {41, 43, 44, 255},
15-
darkGrayAlpha = {41, 43, 44, 150},
6+
blue = {0.01, 0.46, 0.85, 1.0},
7+
green = {0.36, 0.72, 0.36, 1.0},
8+
cyan = {0.36, 0.75, 0.87, 1.0},
9+
orange = {0.94, 0.68, 0.31, 1.0},
10+
red = {0.85, 0.33, 0.31, 1.0},
11+
black = {0.0, 0.0, 0.0, 1.0},
12+
white = {1.0, 1.0, 1.0, 1.0},
13+
clearGray = {0.97, 0.97, 0.97, 1.0},
14+
darkGray = {0.16, 0.17, 0.17, 1.0},
15+
darkGrayAlpha = {0.16, 0.17, 0.17, 0.59},
1616
}
1717
component.style = {
1818
bgColor = component.colors.blue,
@@ -91,7 +91,7 @@ function component.new(t, x, y, w, h, group)
9191
color = gooi.toRGBA(color)
9292
end
9393
self.style.bgColor = color
94-
self.style.borderColor = {color[1], color[2], color[3], 255}
94+
self.style.borderColor = {color[1], color[2], color[3], 1}
9595
self:make3d()
9696
return self
9797
end
@@ -119,10 +119,10 @@ function component.new(t, x, y, w, h, group)
119119
if not w then return self.style.borderWidth, self.style.borderColor; end
120120

121121
self.style.borderWidth = w
122-
self.style.borderColor = color or {12, 183, 242, 255}
122+
self.style.borderColor = color or {0.05, 0.72, 0.95, 1}
123123
if type(color) == "string" then
124124
self.style.borderColor = gooi.toRGBA(color)
125-
self.style.borderColor[4] = 255
125+
self.style.borderColor[4] = 1
126126
end
127127
self.style.borderStyle = style or "smooth"
128128
self.style.showBorder = true
@@ -136,19 +136,19 @@ function component.new(t, x, y, w, h, group)
136136
self.mode3d = false
137137
return self
138138
end
139-
139+
140140
c.style = gooi.deepcopy(component.style)
141141

142142
function c:make3d()
143143
-- For a 3D look:
144144
self.colorTop = self.style.bgColor
145145
self.colorBot = self.style.bgColor
146146

147-
self.colorTop = changeBrig(self.style.bgColor, 15)
148-
self.colorBot = changeBrig(self.style.bgColor, -15)
147+
self.colorTop = changeBrig(self.style.bgColor, 0.06)
148+
self.colorBot = changeBrig(self.style.bgColor, -0.06)
149149

150-
self.colorTopHL = changeBrig(self.style.bgColor, 25)
151-
self.colorBotHL = changeBrig(self.style.bgColor, -5)
150+
self.colorTopHL = changeBrig(self.style.bgColor, 0.1)
151+
self.colorBotHL = changeBrig(self.style.bgColor, -0.02)
152152

153153
self.imgData3D = love.image.newImageData(1, 2)
154154
self.imgData3D:setPixel(0, 0, self.colorTop[1], self.colorTop[2], self.colorTop[3], self.colorTop[4])
@@ -165,19 +165,19 @@ function component.new(t, x, y, w, h, group)
165165
self.img3DHL:setFilter("linear", "linear")
166166

167167
self.imgDataGlass = love.image.newImageData(1, 2)
168-
self.imgDataGlass:setPixel(0, 0, 255, 255, 255, 80)
169-
self.imgDataGlass:setPixel(0, 1, 255, 255, 255, 40)
168+
self.imgDataGlass:setPixel(0, 0, 1, 1, 1, 0.31)
169+
self.imgDataGlass:setPixel(0, 1, 1, 1, 1, 0.16)
170170
self.imgGlass = love.graphics.newImage(self.imgDataGlass)
171171
self.imgGlass:setFilter("linear", "linear")
172172
end
173173

174174
function c:makeShadow()
175175
self.heightShadow = 6
176176
self.imgDataShadow = love.image.newImageData(1, self.heightShadow)
177-
self.imgDataShadow:setPixel(0, 0, 0, 0, 0, 80)
178-
self.imgDataShadow:setPixel(0, 1, 0, 0, 0, 30)
179-
self.imgDataShadow:setPixel(0, 2, 0, 0, 0, 5)
180-
177+
self.imgDataShadow:setPixel(0, 0, 0, 0, 0, 0.31)
178+
self.imgDataShadow:setPixel(0, 1, 0, 0, 0, 0.12)
179+
self.imgDataShadow:setPixel(0, 2, 0, 0, 0, 0.02)
180+
181181
self.imgShadow = love.graphics.newImage(self.imgDataShadow)
182182
self.imgShadow:setFilter("linear", "linear")
183183
end
@@ -188,7 +188,7 @@ function component.new(t, x, y, w, h, group)
188188
function c:info() self:bg(component.colors.cyan); return self end
189189
function c:warning() self:bg(component.colors.orange); return self end
190190
function c:danger() self:bg(component.colors.red); return self end
191-
function c:opacity(o) self.style.bgColor[4] = o * 255; return self end
191+
function c:opacity(o) self.style.bgColor[4] = o; return self end
192192

193193
function c:secondary()
194194
self:bg(component.colors.clearGray)
@@ -203,7 +203,7 @@ function component.new(t, x, y, w, h, group)
203203

204204

205205
c:make3d()
206-
206+
207207
return setmetatable(c, component)
208208
end
209209

@@ -214,7 +214,7 @@ end
214214
function component:draw()-- Every component has the same base:
215215
local style = self.style
216216
if self.opaque and self.visible then
217-
local focusColorChange = 15
217+
local focusColorChange = 0.06
218218
local fs = - 1
219219
if not self.enabled then focusColorChange = 0 end
220220
local newColor = style.bgColor
@@ -236,7 +236,7 @@ function component:draw()-- Every component has the same base:
236236
love.graphics.setColor(newColor)
237237

238238
if not self.enabled then
239-
love.graphics.setColor(63, 63, 63, style.bgColor[4] or 255)
239+
love.graphics.setColor(1/4, 1/4, 1/4, style.bgColor[4] or 1)
240240
end
241241

242242
local radiusCorner = style.radius
@@ -270,9 +270,9 @@ function component:draw()-- Every component has the same base:
270270
end
271271

272272
if self.mode3d then
273-
love.graphics.setColor(255, 255, 255, style.bgColor[4] or 255)
273+
love.graphics.setColor(1, 1, 1, style.bgColor[4] or 1)
274274
if not self.enabled then
275-
love.graphics.setColor(0, 0, 0, style.bgColor[4] or 255)
275+
love.graphics.setColor(0, 0, 0, style.bgColor[4] or 1)
276276
end
277277
love.graphics.draw(img,
278278
math.floor(self.x + self.w / 2),
@@ -296,7 +296,7 @@ function component:draw()-- Every component has the same base:
296296
end
297297

298298
if self.glass then
299-
love.graphics.setColor(255, 255, 255)
299+
love.graphics.setColor(1, 1, 1)
300300
love.graphics.draw(self.imgGlass,
301301
self.x,
302302
self.y,
@@ -306,7 +306,7 @@ function component:draw()-- Every component has the same base:
306306
end
307307

308308
if self.bgImage then
309-
love.graphics.setColor(255, 255, 255)
309+
love.graphics.setColor(1, 1, 1)
310310
love.graphics.draw(self.bgImage,
311311
math.floor(self.x),
312312
math.floor(self.y),
@@ -320,7 +320,7 @@ function component:draw()-- Every component has the same base:
320320
if style.showBorder then
321321
love.graphics.setColor(newColor)
322322
if not self.enabled then
323-
love.graphics.setColor(63, 63, 63)
323+
love.graphics.setColor(1/4, 1/4, 1/4)
324324
end
325325
love.graphics.rectangle("line",
326326
math.floor(self.x),
@@ -348,7 +348,7 @@ function component:drawShadowPressed()
348348
end, "replace", 1)
349349
love.graphics.setStencilTest("greater", 0)
350350

351-
love.graphics.setColor(255, 255, 255)
351+
love.graphics.setColor(1, 1, 1)
352352
love.graphics.draw(self.imgShadow,
353353
self.x + self.w / 2,
354354
self.y + self.h / 2,
@@ -397,7 +397,7 @@ function component:wasReleased()
397397
local b = self:overIt() and self.enabled and self.visible
398398
if self.type == "text" then
399399
if b then
400-
love.keyboard.setTextInput(true)
400+
love.keyboard.setTextInput(true)
401401
end
402402
end
403403

@@ -517,24 +517,24 @@ function changeBrig(color, amount)
517517
color = gooi.toRGBA(color)
518518
end
519519

520-
local r, g, b, a = color[1], color[2], color[3], color[4] or 255
520+
local r, g, b, a = color[1], color[2], color[3], color[4] or 1
521521

522522
r = r + amount
523523
g = g + amount
524524
b = b + amount
525525
--a = a + amount
526526

527527
if r < 0 then r = 0 end
528-
if r > 255 then r = 255 end
528+
if r > 1 then r = 1 end
529529

530530
if g < 0 then g = 0 end
531-
if g > 255 then g = 255 end
531+
if g > 1 then g = 1 end
532532

533533
if b < 0 then b = 0 end
534-
if b > 255 then b = 255 end
534+
if b > 1 then b = 1 end
535535

536536
--if a < 0 then a = 0 end
537-
--if a > 255 then a = 255 end
537+
--if a > 1 then a = 1 end
538538

539539
return {r, g, b, a}
540540
end

gooi/gooi.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function gooi.draw(group)
348348

349349
local compWithTooltip = nil -- Just for desktop.
350350

351-
love.graphics.setColor(255, 255, 255)
351+
love.graphics.setColor(1, 1, 1)
352352
love.graphics.setLineWidth(2)
353353
love.graphics.setLineStyle(gooi.lineStyle)
354354

@@ -379,7 +379,7 @@ function gooi.draw(group)
379379

380380
local fg = comp.style.fgColor
381381
if not comp.enabled then
382-
fg = {31, 31, 31}
382+
fg = {0.12, 0.12, 0.12}
383383
end
384384

385385
------------------------------------------------------------
@@ -415,7 +415,7 @@ function gooi.draw(group)
415415
xTT = xTT - ttf:getWidth(text)
416416
end
417417

418-
love.graphics.setColor(0, 0, 0, 150)
418+
love.graphics.setColor(0, 0, 0, 0.6)
419419
love.graphics.rectangle("fill",
420420
xTT - httf,
421421
math.floor((love.mouse.getY() / gooi.sy) - httf * 1.5),
@@ -433,7 +433,7 @@ function gooi.draw(group)
433433
love.graphics.setFont(gooi.getFont(self))-- Specific or a common font.
434434
local w, h = gooi.canvas:getWidth(), gooi.canvas:getHeight()
435435

436-
love.graphics.setColor(0, 0, 0, 127)
436+
love.graphics.setColor(0, 0, 0, 0.5)
437437
love.graphics.rectangle("fill", 0, 0,
438438
love.graphics.getWidth(),
439439
love.graphics.getHeight())
@@ -495,9 +495,11 @@ end
495495

496496
function gooi.toRGBA(hex)
497497
hex = hex:gsub("#","")
498-
color = {tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))}
498+
color = {tonumber("0x"..hex:sub(1,2))/255,
499+
tonumber("0x"..hex:sub(3,4))/255,
500+
tonumber("0x"..hex:sub(5,6))/255}
499501
if string.len(hex) >= 8 then
500-
table.insert(color, tonumber("0x"..hex:sub(7, 8)))
502+
table.insert(color, tonumber("0x"..hex:sub(7, 8))/255)
501503
end
502504
return color
503505
end
@@ -806,6 +808,6 @@ function split(inputstr, sep)
806808
end
807809

808810
function invert(color)
809-
local r, g, b, a = color[1], color[2], color[3], color[4] or 255
810-
return {255 - r, 255 - g, 255 - b, a}
811+
local r, g, b, a = color[1], color[2], color[3], color[4] or 1
812+
return {1 - r, 1 - g, 1 - b, a}
811813
end

gooi/joy.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function gooi.newJoy(params)
7171
function s:drawStick()
7272
local fg = self.style.fgColor
7373
if self.image then
74-
love.graphics.setColor(255, 255, 255, fg[4] or 255)
74+
love.graphics.setColor(1, 1, 1, fg[4] or 1)
7575
local sx = self.rStick * 2 / self.image:getWidth()
7676
local sy = self.rStick * 2 / self.image:getHeight()
7777
local x, y = self.xStick, self.yStick

gooi/knob.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function gooi.newKnob(params)
5555

5656
love.graphics.setColor(fg)
5757
if not self.enabled then
58-
love.graphics.setColor(63, 63, 63)
58+
love.graphics.setColor(1/4, 1/4, 1/4)
5959
end
6060
love.graphics.arc("line",
6161
"open",

gooi/label.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function gooi.newLabel(params)
6666
end
6767
if self.icon then
6868
local xImg = math.floor(self.x + self.h / 2)
69-
love.graphics.setColor(255, 255, 255)
70-
if not self.enabled then love.graphics.setColor(63, 63, 63) end
69+
love.graphics.setColor(1, 1, 1)
70+
if not self.enabled then love.graphics.setColor(1/4, 1/4, 1/4) end
7171

7272
if t:len() == 0 then
7373
xImg = math.floor(self.x + self.w / 2)

gooi/layout.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function layout.new(specs)
3535
for j = 1, self.gridCols do
3636
local cell = self.gridCells[i][j]
3737
if cell.on then
38-
love.graphics.setColor(255, 0, 255)
38+
love.graphics.setColor(1, 0, 1)
3939
love.graphics.rectangle("line", cell.x, cell.y, cell.w, cell.h)
4040
end
4141
end

gooi/panel.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function gooi.newPanel(params)
4747
end
4848
function p:drawSpecifics(fg)
4949
if self.layout.kind == "grid" then
50-
love.graphics.setColor(0, 0, 0, 127)
50+
love.graphics.setColor(0, 0, 0, 0.5)
5151
self.layout:drawCells()
5252
end
5353
end

0 commit comments

Comments
 (0)