diff --git a/src/styles.cr b/src/styles.cr index 08dba64..9b2686d 100644 --- a/src/styles.cr +++ b/src/styles.cr @@ -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