Commit 99fb5d0a authored by Andreas Schildbach's avatar Andreas Schildbach

color.py: Change wording lightness to brightness.

parent f3d7d710
Pipeline #1967 passed with stages
in 1 minute and 7 seconds
......@@ -96,9 +96,9 @@ class Color(_ColorTuple):
return cls(f2(5), f2(3), f2(1))
@classmethod
def from_hsl(cls, hue, saturation, lightness):
def from_hsl(cls, hue, saturation, brightness):
"""
Create a color from a HSL tuple (hue, saturation, lightness).
Create a color from a HSL tuple (hue, saturation, brightness).
This function is available both as a class method and directly inside
the color module:
......@@ -122,11 +122,11 @@ class Color(_ColorTuple):
Code via https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
"""
a = saturation * min(lightness, 1 - lightness)
a = saturation * min(brightness, 1 - brightness)
def f(n):
k = (n + hue / 30) % 12
return lightness - (a * max(min(k - 3, 9 - k, 1), -1))
return brightness - (a * max(min(k - 3, 9 - k, 1), -1))
def f2(x):
return round(f(x) * 255)
......@@ -199,7 +199,7 @@ class Color(_ColorTuple):
def to_hsl(self):
"""
Create a HSL tuple (hue, saturation, lightness) from this color.
Create a HSL tuple (hue, saturation, brightness) from this color.
**Example**:
......@@ -333,10 +333,10 @@ class Color(_ColorTuple):
"""
return self.__change_vlx(change, self.to_hsv, self.from_hsv)
def change_lightness(self, change):
def change_brightness(self, change):
"""
Change the lightness of this color (in HSL).
Lightness is always between 0 and 1.
Change the brightness of this color (in HSL).
Brightness is always between 0 and 1.
**Example**:
......@@ -348,7 +348,7 @@ class Color(_ColorTuple):
c = Color.from_hex(0xff0000)
print(c)
# #ff0000
c.change_lightness(0.2)
c.change_brightness(0.2)
print(c)
# #ff6666
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment