mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-12-12 13:44:18 +00:00
Hack luminance tweaking for creating highlight color (needs a proper implementation)
This commit is contained in:
parent
be12e0f4f1
commit
86a5894429
@ -173,17 +173,19 @@ module Tartrazine
|
||||
|
||||
# If the color is dark, make it brighter and viceversa
|
||||
def self.make_highlight_color(base_color)
|
||||
# FIXME: do a proper luminance adjustment in the color class
|
||||
return nil if base_color.nil?
|
||||
color = Color.new(base_color.hex)
|
||||
if base_color.light?
|
||||
color.r = [(base_color.r / 1.2), 255].min.to_u8
|
||||
color.g = [(base_color.g / 1.2), 255].min.to_u8
|
||||
color.b = [(base_color.b / 1.2), 255].min.to_u8
|
||||
color.r = [(base_color.r - 40), 255].min.to_u8
|
||||
color.g = [(base_color.g - 40), 255].min.to_u8
|
||||
color.b = [(base_color.b - 40), 255].min.to_u8
|
||||
else
|
||||
color.r = [(base_color.r * 1.2), 255].min.to_u8
|
||||
color.g = [(base_color.g * 1.2), 255].min.to_u8
|
||||
color.b = [(base_color.b * 1.2), 255].min.to_u8
|
||||
color.r = [(base_color.r + 40), 255].min.to_u8
|
||||
color.g = [(base_color.g + 40), 255].min.to_u8
|
||||
color.b = [(base_color.b + 40), 255].min.to_u8
|
||||
end
|
||||
# Bug in color, setting rgb doesn't update hex
|
||||
color.hex = "#{color.r.to_s(16)}#{color.g.to_s(16)}#{color.b.to_s(16)}"
|
||||
color
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user