fleshed out opacity

This commit is contained in:
Michael Freno
2025-09-17 18:34:54 -04:00
parent 2256dd4345
commit 757819e4a3

View File

@@ -721,7 +721,9 @@ function Element:draw()
end end
end end
love.graphics.setColor(drawBackground:toRGBA()) -- Apply opacity to all drawing operations
local backgroundWithOpacity = Color.new(drawBackground.r, drawBackground.g, drawBackground.b, drawBackground.a * self.opacity)
love.graphics.setColor(backgroundWithOpacity:toRGBA())
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",
self.x - self.padding.left, self.x - self.padding.left,
@@ -730,7 +732,8 @@ function Element:draw()
self.height + self.padding.top + self.padding.bottom self.height + self.padding.top + self.padding.bottom
) )
-- Draw borders based on border property -- Draw borders based on border property
love.graphics.setColor(self.borderColor:toRGBA()) local borderColorWithOpacity = Color.new(self.borderColor.r, self.borderColor.g, self.borderColor.b, self.borderColor.a * self.opacity)
love.graphics.setColor(borderColorWithOpacity:toRGBA())
if self.border.top then if self.border.top then
love.graphics.line( love.graphics.line(
self.x - self.padding.left, self.x - self.padding.left,
@@ -766,7 +769,8 @@ function Element:draw()
-- Draw element text if present -- Draw element text if present
if self.text then if self.text then
love.graphics.setColor(self.textColor:toRGBA()) local textColorWithOpacity = Color.new(self.textColor.r, self.textColor.g, self.textColor.b, self.textColor.a * self.opacity)
love.graphics.setColor(textColorWithOpacity:toRGBA())
local origFont = love.graphics.getFont() local origFont = love.graphics.getFont()
local tempFont local tempFont
@@ -800,7 +804,7 @@ function Element:draw()
-- Draw visual feedback when element is pressed (if it has a callback) -- Draw visual feedback when element is pressed (if it has a callback)
if self.callback and self._pressed then if self.callback and self._pressed then
love.graphics.setColor(0.5, 0.5, 0.5, 0.3) -- Semi-transparent gray for pressed state love.graphics.setColor(0.5, 0.5, 0.5, 0.3 * self.opacity) -- Semi-transparent gray for pressed state with opacity
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",
self.x - self.padding.left, self.x - self.padding.left,