Return white line for dark backgrounds

This commit is contained in:
DarkPhoenix
2019-08-07 09:48:39 +03:00
parent ae5e0cc71a
commit dd5c95d2f2

View File

@@ -39,8 +39,12 @@ class LineStyleData:
@property
def iconName(self):
# TODO: add code to use white icon if background is dark
return '{}_black'.format(self._iconNamePrefix)
# Get lightness out of RGB color, see following link for math:
# https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/
r, g, b, a = (c / 255 for c in wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
l = (max(r, g, b) + min (r, g, b)) / 2
suffix = '_black' if l > 0.3 else '_white'
return '{}{}'.format(self._iconNamePrefix, suffix)
# In HSL format