[+] Implement color overlaying
This commit is contained in:
parent
f20e80375a
commit
9914ff2a55
1 changed files with 10 additions and 0 deletions
|
@ -239,3 +239,13 @@ class RGB:
|
||||||
|
|
||||||
def is_light(self):
|
def is_light(self):
|
||||||
return self.hsl().l > 0.5
|
return self.hsl().l > 0.5
|
||||||
|
|
||||||
|
def overlay(self, color: 'RGB', alpha: float) -> 'RGB':
|
||||||
|
"""
|
||||||
|
Overlay a color on top of this color
|
||||||
|
|
||||||
|
:param color: Overlay color
|
||||||
|
:param alpha: Overlay alpha
|
||||||
|
:return: New color (original isn't modified)
|
||||||
|
"""
|
||||||
|
return RGB(*[round((1 - alpha) * v1 + alpha * v2) for v1, v2 in zip(self, color)])
|
||||||
|
|
Loading…
Reference in a new issue