MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / _rgb_to_hsl

Function _rgb_to_hsl

PySimpleGUI/PySimpleGUI.py:20161–20180  ·  view source on GitHub ↗
(r, g, b)

Source from the content-addressed store, hash-verified

20159
20160
20161def _rgb_to_hsl(r, g, b):
20162 r = float(r)
20163 g = float(g)
20164 b = float(b)
20165 high = max(r, g, b)
20166 low = min(r, g, b)
20167 h, s, v = ((high + low) / 2,) * 3
20168 if high == low:
20169 h = s = 0.0
20170 else:
20171 d = high - low
20172 l = (high + low) / 2
20173 s = d / (2 - high - low) if l > 0.5 else d / (high + low)
20174 h = {
20175 r: (g - b) / d + (6 if g < b else 0),
20176 g: (b - r) / d + 2,
20177 b: (r - g) / d + 4,
20178 }[high]
20179 h /= 6
20180 return h, s, v
20181
20182
20183def _hsl_to_rgb(h, s, l):

Callers 1

_hex_to_hslFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected