Skip to content

Commit

Permalink
fix(lib/Color): Color.lumanance -> Color.luminance
Browse files Browse the repository at this point in the history
Correct misspelling of "luminance". Rename function `Color:lumanance()`
of the `Color` library to `Color:luminance()`.
  • Loading branch information
tmillr committed Jul 11, 2024
1 parent 6829ce3 commit c96c1f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/github-theme/lib/color.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ function Color:to_css(with_alpha)
return string.format('#%0' .. l .. 'x', n)
end

---Calculate the relative lumanance of the color
---Calculate the relative luminance of the color
---https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
---@return number
function Color:lumanance()
function Color:luminance()
local r, g, b = self.red, self.green, self.blue
r = (r > 0.04045) and ((r + 0.055) / 1.055) ^ 2.4 or (r / 12.92)
g = (g > 0.04045) and ((g + 0.055) / 1.055) ^ 2.4 or (g / 12.92)
Expand Down Expand Up @@ -346,8 +346,8 @@ Color.BG = Color.init(0, 0, 0, 1)
---Returns the contrast ratio of the other against another
---@param other Color
function Color:contrast(other)
local l1 = self:lumanance()
local l2 = other:lumanance()
local l1 = self:luminance()
local l2 = other:luminance()
if l2 > l1 then
l1, l2 = l2, l1
end
Expand Down

0 comments on commit c96c1f0

Please sign in to comment.