From 0d89e351e1c8347e592e68a6c3c3825fd19fb749 Mon Sep 17 00:00:00 2001 From: Fredrik Lundh Date: Sat, 12 Nov 2005 15:21:05 +0000 Subject: r879@spiff: Fredrik | 2005-11-12 14:38:03 +0100 r878@spiff: Fredrik | 2005-11-12 14:37:22 +0100 minor docstring and comment tweaks (wikipedia might not be the ultimate reference, but it's a lot better than "XXX" ;-) --- Lib/colorsys.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Lib/colorsys.py b/Lib/colorsys.py index c2cdf57..39b4b16 100644 --- a/Lib/colorsys.py +++ b/Lib/colorsys.py @@ -5,17 +5,21 @@ This modules provides two functions for each color system ABC: rgb_to_abc(r, g, b) --> a, b, c abc_to_rgb(a, b, c) --> r, g, b -All inputs and outputs are triples of floats in the range [0.0...1.0]. -Inputs outside this range may cause exceptions or invalid outputs. +All inputs and outputs are triples of floats in the range [0.0...1.0] +(with the exception of I and Q, which covers a slightly larger range). +Inputs outside the valid range may cause exceptions or invalid outputs. Supported color systems: RGB: Red, Green, Blue components -YIQ: used by composite video signals +YIQ: Luminance, Chrominance (used by composite video signals) HLS: Hue, Luminance, Saturation HSV: Hue, Saturation, Value """ + # References: -# XXX Where's the literature? +# http://en.wikipedia.org/wiki/YIQ +# http://en.wikipedia.org/wiki/HLS_color_space +# http://en.wikipedia.org/wiki/HSV_color_space __all__ = ["rgb_to_yiq","yiq_to_rgb","rgb_to_hls","hls_to_rgb", "rgb_to_hsv","hsv_to_rgb"] @@ -26,7 +30,6 @@ ONE_THIRD = 1.0/3.0 ONE_SIXTH = 1.0/6.0 TWO_THIRD = 2.0/3.0 - # YIQ: used by composite video signals (linear combinations of RGB) # Y: perceived grey level (0.0 == black, 1.0 == white) # I, Q: color components @@ -50,10 +53,10 @@ def yiq_to_rgb(y, i, q): return (r, g, b) -# HLS: Hue, Luminance, S??? +# HLS: Hue, Luminance, Saturation # H: position in the spectrum -# L: ??? -# S: ??? +# L: color lightness +# S: color saturation def rgb_to_hls(r, g, b): maxc = max(r, g, b) @@ -87,10 +90,10 @@ def _v(m1, m2, hue): return m1 -# HSV: Hue, Saturation, Value(?) +# HSV: Hue, Saturation, Value # H: position in the spectrum -# S: ??? -# V: ??? +# S: color saturation ("purity") +# V: color brightness def rgb_to_hsv(r, g, b): maxc = max(r, g, b) -- cgit v0.12