Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit bf8ab8a

Browse files
committed
Adding notes to RGB classes about value scaling.
1 parent c1712e8 commit bf8ab8a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

colormath/color_objects.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,23 +555,23 @@ def _clamp_rgb_coordinate(self, coord):
555555
@property
556556
def clamped_rgb_r(self):
557557
"""
558-
The clamped (0-1 or 1-255) R value.
558+
The clamped (0.0-1.0) R value.
559559
"""
560560

561561
return self._clamp_rgb_coordinate(self.rgb_r)
562562

563563
@property
564564
def clamped_rgb_g(self):
565565
"""
566-
The clamped (0-1 or 1-255) G value.
566+
The clamped (0.0-1.0) G value.
567567
"""
568568

569569
return self._clamp_rgb_coordinate(self.rgb_g)
570570

571571
@property
572572
def clamped_rgb_b(self):
573573
"""
574-
The clamped (0-1 or 1-255) B value.
574+
The clamped (0.0-1.0) B value.
575575
"""
576576

577577
return self._clamp_rgb_coordinate(self.rgb_b)
@@ -581,9 +581,6 @@ def get_upscaled_value_tuple(self):
581581
Scales an RGB color object from decimal 0.0-1.0 to int 0-255.
582582
"""
583583

584-
if self.is_upscaled:
585-
return self.get_value_tuple()
586-
587584
# Scale up to 0-255 values.
588585
rgb_r = int(math.floor(0.5 + self.rgb_r * 255))
589586
rgb_g = int(math.floor(0.5 + self.rgb_g * 255))
@@ -625,6 +622,10 @@ class sRGBColor(BaseRGBColor):
625622
"""
626623
Represents an sRGB color.
627624
625+
.. note:: If you pass in upscaled values, we automatically scale them
626+
down to 0.0-1.0. If you need the old upscaled values, you can
627+
retrieve them with :py:meth:`get_upscaled_value_tuple`.
628+
628629
:ivar float rgb_r: R coordinate
629630
:ivar float rgb_g: G coordinate
630631
:ivar float rgb_b: B coordinate
@@ -654,6 +655,10 @@ class AdobeRGBColor(BaseRGBColor):
654655
"""
655656
Represents an Adobe RGB color.
656657
658+
.. note:: If you pass in upscaled values, we automatically scale them
659+
down to 0.0-1.0. If you need the old upscaled values, you can
660+
retrieve them with :py:meth:`get_upscaled_value_tuple`.
661+
657662
:ivar float rgb_r: R coordinate
658663
:ivar float rgb_g: G coordinate
659664
:ivar float rgb_b: B coordinate

0 commit comments

Comments
 (0)