diff options
Diffstat (limited to 'thcolor/colors.py')
-rw-r--r-- | thcolor/colors.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/thcolor/colors.py b/thcolor/colors.py index 935dc72..79394dd 100644 --- a/thcolor/colors.py +++ b/thcolor/colors.py @@ -564,7 +564,15 @@ class SRGBColor(Color): def asyiq(self) -> 'YIQColor': """ Get an YIQColor out of the current object. """ - raise NotImplementedError # TODO + r, g, b = self.red, self.green, self.blue + y = .3 * r + .59 * g + .11 * b + + return YIQColor( + y=y, + i=.74 * (r - y) - .27 * (b - y), + q=.48 * (r - y) + .41 * (b - y), + alpha=self.alpha, + ) def asyuv(self) -> 'YUVColor': """ Get an YUVColor out of the current object. """ @@ -1190,7 +1198,20 @@ class YIQColor(Color): def assrgb(self) -> 'SRGBColor': """ Get an SRGBColor out of the current object. """ - raise NotImplementedError # TODO + y, i, q = self.y, self.i, self.q + + return SRGBColor( + red=max(0.0, min(1.0, ( + y + .9468822170900693 * i + .6235565819861433 * q + ))), + green=max(0.0, min(1.0, ( + y - .27478764629897834 * i - .6356910791873801 * q + ))), + blue=max(0.0, min(1.0, ( + y - 1.1085450346420322 * i + 1.7090069284064666 * q + ))), + alpha=self.alpha, + ) def asyiq(self) -> 'YIQColor': """ Get an YIQColor out of the current object. """ |