Skip to content

Commit

Permalink
Drop gray from the highlight colors, and let colorFromName return nil
Browse files Browse the repository at this point in the history
This allows us to fairly easily make gray behave as our legacy grayscale
highlights, honoring the user's opacity value.
  • Loading branch information
NiLuJe committed Aug 25, 2024
1 parent 5c6534d commit a7710f9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ffi/blitbuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ function BB.gray(level)
end

--[[
return a Color value resembling a given hex string
return a Color value resembling a given hex string (nil on failure)
--]]
function BB.colorFromString(value)
value = value:gsub('#','')
Expand Down Expand Up @@ -2601,13 +2601,14 @@ BB.HIGHLIGHT_COLORS = {
["cyan"] = "#00FFEE",
["blue"] = "#0066FF",
["purple"] = "#EE00FF",
["gray"] = "#CCCCCC", -- Matches the default highlight style on grayscale screens (i.e., darkenRect by 0.2)
}
--[[
return a Color value given a common color name (fall back to gray for unknown colors)
return a Color value given a common color name (nil for unknown colors)
--]]
function BB.colorFromName(name)
return BB.colorFromString(BB.HIGHLIGHT_COLORS[name:lower()] or "#808080")
local color_hash = BB.HIGHLIGHT_COLORS[name:lower()]
if not color_hash then return nil end
return BB.colorFromString(color_hash)
end

--[[
Expand Down

0 comments on commit a7710f9

Please sign in to comment.