From dd5c95d2f290a1c985a1ce5f0998f0173f4fbdf3 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 7 Aug 2019 09:48:39 +0300 Subject: [PATCH] Return white line for dark backgrounds --- graphs/style.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/graphs/style.py b/graphs/style.py index 84f15d520..56dd99819 100644 --- a/graphs/style.py +++ b/graphs/style.py @@ -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