@@ -133,6 +133,9 @@ class SpectralColor(IlluminantMixin, ColorBase):
133133 Spectral colors are the lowest level, most "raw" measurement of color.
134134 You may convert spectral colors to any other color space, but you can't
135135 convert any other color space back to spectral.
136+
137+ See `Spectral power distribution <http://en.wikipedia.org/wiki/Spectral_power_distribution>`_
138+ on Wikipedia for some higher level details on how these work.
136139 """
137140
138141 VALUES = [
@@ -166,8 +169,8 @@ def __init__(self,
166169 spec_780nm = 0.0 , spec_790nm = 0.0 , spec_800nm = 0.0 , spec_810nm = 0.0 ,
167170 spec_820nm = 0.0 , spec_830nm = 0.0 , observer = '2' , illuminant = 'd50' ):
168171 """
169- :param str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
170- :param illuminant: See :doc:`illuminants` for valid values.
172+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
173+ :keyword str illuminant: See :doc:`illuminants` for valid values.
171174 """
172175
173176 super (SpectralColor , self ).__init__ ()
@@ -268,12 +271,22 @@ def calc_density(self, density_standard=None):
268271
269272class LabColor (IlluminantMixin , ColorBase ):
270273 """
271- Represents an Lab color.
274+ Represents a CIE Lab color. For more information on CIE Lab,
275+ see `Lab color space <http://en.wikipedia.org/wiki/Lab_color_space>`_ on
276+ Wikipedia.
272277 """
273278
274279 VALUES = ['lab_l' , 'lab_a' , 'lab_b' ]
275280
276281 def __init__ (self , lab_l , lab_a , lab_b , observer = '2' , illuminant = 'd50' ):
282+ """
283+ :param float lab_l: L coordinate.
284+ :param float lab_a: a coordinate.
285+ :param float lab_b: b coordinate.
286+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
287+ :keyword str illuminant: See :doc:`illuminants` for valid values.
288+ """
289+
277290 super (LabColor , self ).__init__ ()
278291 self .lab_l = float (lab_l )
279292 self .lab_a = float (lab_a )
@@ -284,12 +297,25 @@ def __init__(self, lab_l, lab_a, lab_b, observer='2', illuminant='d50'):
284297
285298class LCHabColor (IlluminantMixin , ColorBase ):
286299 """
287- Represents an LCHab color.
300+ Represents an CIE LCH color that was converted to LCH by passing through
301+ CIE Lab. This differs from :py:class:`LCHuvColor`, which was converted to
302+ LCH through CIE Luv.
303+
304+ See `Introduction to Colour Spaces <http://www.colourphil.co.uk/lab_lch_colour_space.shtml>`_
305+ by Phil Cruse for an illustration of how CIE LCH differs from CIE Lab.
288306 """
289307
290308 VALUES = ['lch_l' , 'lch_c' , 'lch_h' ]
291309
292310 def __init__ (self , lch_l , lch_c , lch_h , observer = '2' , illuminant = 'd50' ):
311+ """
312+ :param float lch_l: L coordinate.
313+ :param float lch_c: C coordinate.
314+ :param float lch_h: H coordinate.
315+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
316+ :keyword str illuminant: See :doc:`illuminants` for valid values.
317+ """
318+
293319 super (LCHabColor , self ).__init__ ()
294320 self .lch_l = float (lch_l )
295321 self .lch_c = float (lch_c )
@@ -300,12 +326,25 @@ def __init__(self, lch_l, lch_c, lch_h, observer='2', illuminant='d50'):
300326
301327class LCHuvColor (IlluminantMixin , ColorBase ):
302328 """
303- Represents an LCHuv color.
329+ Represents an CIE LCH color that was converted to LCH by passing through
330+ CIE Luv. This differs from :py:class:`LCHabColor`, which was converted to
331+ LCH through CIE Lab.
332+
333+ See `Introduction to Colour Spaces <http://www.colourphil.co.uk/lab_lch_colour_space.shtml>`_
334+ by Phil Cruse for an illustration of how CIE LCH differs from CIE Lab.
304335 """
305336
306337 VALUES = ['lch_l' , 'lch_c' , 'lch_h' ]
307338
308339 def __init__ (self , lch_l , lch_c , lch_h , observer = '2' , illuminant = 'd50' ):
340+ """
341+ :param float lch_l: L coordinate.
342+ :param float lch_c: C coordinate.
343+ :param float lch_h: H coordinate.
344+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
345+ :keyword str illuminant: See :doc:`illuminants` for valid values.
346+ """
347+
309348 super (LCHuvColor , self ).__init__ ()
310349 self .lch_l = float (lch_l )
311350 self .lch_c = float (lch_c )
@@ -322,6 +361,14 @@ class LuvColor(IlluminantMixin, ColorBase):
322361 VALUES = ['luv_l' , 'luv_u' , 'luv_v' ]
323362
324363 def __init__ (self , luv_l , luv_u , luv_v , observer = '2' , illuminant = 'd50' ):
364+ """
365+ :param float luv_l: L coordinate.
366+ :param float luv_u: u coordinate.
367+ :param float luv_v: v coordinate.
368+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
369+ :keyword str illuminant: See :doc:`illuminants` for valid values.
370+ """
371+
325372 super (LuvColor , self ).__init__ ()
326373 self .luv_l = float (luv_l )
327374 self .luv_u = float (luv_u )
@@ -338,6 +385,14 @@ class XYZColor(IlluminantMixin, ColorBase):
338385 VALUES = ['xyz_x' , 'xyz_y' , 'xyz_z' ]
339386
340387 def __init__ (self , xyz_x , xyz_y , xyz_z , observer = '2' , illuminant = 'd50' ):
388+ """
389+ :param float xyz_x: X coordinate.
390+ :param float xyz_y: Y coordinate.
391+ :param float xyz_z: Z coordinate.
392+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
393+ :keyword str illuminant: See :doc:`illuminants` for valid values.
394+ """
395+
341396 super (XYZColor , self ).__init__ ()
342397 self .xyz_x = float (xyz_x )
343398 self .xyz_y = float (xyz_y )
@@ -376,6 +431,14 @@ class xyYColor(IlluminantMixin, ColorBase):
376431 VALUES = ['xyy_x' , 'xyy_y' , 'xyy_Y' ]
377432
378433 def __init__ (self , xyy_x , xyy_y , xyy_Y , observer = '2' , illuminant = 'd50' ):
434+ """
435+ :param float xyy_x: x coordinate.
436+ :param float xyy_y: y coordinate.
437+ :param float xyy_Y: Y coordinate.
438+ :keyword str observer: Observer angle. Either ``'2'`` or ``'10'`` degrees.
439+ :keyword str illuminant: See :doc:`illuminants` for valid values.
440+ """
441+
379442 super (xyYColor , self ).__init__ ()
380443 self .xyy_x = float (xyy_x )
381444 self .xyy_y = float (xyy_y )
@@ -394,6 +457,14 @@ class BaseRGBColor(ColorBase):
394457 VALUES = ['rgb_r' , 'rgb_g' , 'rgb_b' ]
395458
396459 def __init__ (self , rgb_r , rgb_g , rgb_b , is_upscaled = False ):
460+ """
461+ :param float rgb_r: R coordinate. 0...1. 1-255 if is_upscaled=True.
462+ :param float rgb_g: G coordinate. 0...1. 1-255 if is_upscaled=True.
463+ :param float rgb_b: B coordinate. 0...1. 1-255 if is_upscaled=True.
464+ :keyword bool is_upscaled: If False, RGB coordinate values are
465+ beteween 0.0 and 1.0. If True, RGB values are between 1 and 255.
466+ """
467+
397468 super (BaseRGBColor , self ).__init__ ()
398469 if is_upscaled :
399470 self .rgb_r = rgb_r / 255.0
@@ -403,12 +474,16 @@ def __init__(self, rgb_r, rgb_g, rgb_b, is_upscaled=False):
403474 self .rgb_r = float (rgb_r )
404475 self .rgb_g = float (rgb_g )
405476 self .rgb_b = float (rgb_b )
477+ self .is_upscaled = is_upscaled
406478
407479 def get_upscaled_value_tuple (self ):
408480 """
409481 Scales an RGB color object from decimal 0.0-1.0 to int 0-255.
410482 """
411483
484+ if self .is_upscaled :
485+ return self .get_value_tuple ()
486+
412487 # Scale up to 0-255 values.
413488 rgb_r = int (math .floor (0.5 + self .rgb_r * 255 ))
414489 rgb_g = int (math .floor (0.5 + self .rgb_g * 255 ))
@@ -419,6 +494,8 @@ def get_upscaled_value_tuple(self):
419494 def get_rgb_hex (self ):
420495 """
421496 Converts the RGB value to a hex value in the form of: #RRGGBB
497+
498+ :rtype: str
422499 """
423500
424501 rgb_r , rgb_g , rgb_b = self .get_upscaled_value_tuple ()
@@ -494,6 +571,12 @@ class HSLColor(ColorBase):
494571 VALUES = ['hsl_h' , 'hsl_s' , 'hsl_l' ]
495572
496573 def __init__ (self , hsl_h , hsl_s , hsl_l ):
574+ """
575+ :param float hsl_h: H coordinate.
576+ :param float hsl_s: S coordinate.
577+ :param float hsl_l: L coordinate.
578+ """
579+
497580 super (HSLColor , self ).__init__ ()
498581 self .hsl_h = float (hsl_h )
499582 self .hsl_s = float (hsl_s )
@@ -508,6 +591,12 @@ class HSVColor(ColorBase):
508591 VALUES = ['hsv_h' , 'hsv_s' , 'hsv_v' ]
509592
510593 def __init__ (self , hsv_h , hsv_s , hsv_v ):
594+ """
595+ :param float hsv_h: H coordinate.
596+ :param float hsv_s: S coordinate.
597+ :param float hsv_v: V coordinate.
598+ """
599+
511600 super (HSVColor , self ).__init__ ()
512601 self .hsv_h = float (hsv_h )
513602 self .hsv_s = float (hsv_s )
@@ -522,6 +611,12 @@ class CMYColor(ColorBase):
522611 VALUES = ['cmy_c' , 'cmy_m' , 'cmy_y' ]
523612
524613 def __init__ (self , cmy_c , cmy_m , cmy_y ):
614+ """
615+ :param float cmy_c: C coordinate.
616+ :param float cmy_m: M coordinate.
617+ :param float cmy_y: Y coordinate.
618+ """
619+
525620 super (CMYColor , self ).__init__ ()
526621 self .cmy_c = float (cmy_c )
527622 self .cmy_m = float (cmy_m )
@@ -536,6 +631,13 @@ class CMYKColor(ColorBase):
536631 VALUES = ['cmyk_c' , 'cmyk_m' , 'cmyk_y' , 'cmyk_k' ]
537632
538633 def __init__ (self , cmyk_c , cmyk_m , cmyk_y , cmyk_k ):
634+ """
635+ :param float cmyk_c: C coordinate.
636+ :param float cmyk_m: M coordinate.
637+ :param float cmyk_y: Y coordinate.
638+ :param float cmyk_k: K coordinate.
639+ """
640+
539641 super (CMYKColor , self ).__init__ ()
540642 self .cmyk_c = float (cmyk_c )
541643 self .cmyk_m = float (cmyk_m )
0 commit comments