HSV¶
import introcs
This class represents an HSV color value. As an additive color, it has conversion
methods for tkinter
, kivy
and PIL
. However, most of these methods require
conversion to RGB color space before use.
HSV colors are represented by a cone. Pure color values such as red or green
are positioned at the vertical top of the cone, with a value
of 1.0.
Constructor¶
- class introcs.HSV(h, s, v)¶
An instance is a HSV color value.
The
hue
range is not inclusive on the high end. So 359.99999 is a valid hue, but 360.0 is not. All other color values are inclusive.- Parameters
h (
float
0.0..360.0, not including 360.0) – the initial hues (
float
0.0..1.0) – the initial saturationv (
float
0.0..1.0) – the initial value
Attributes¶
- HSV.hue¶
The hue channel.
Invariant: Value must be a float between 0.0 and 360.0, not including 360.0.
- HSV.saturation¶
The staturation channel.
Invariant: Value must be a float between 0.0 and 1.0, inclusive.
- HSV.value¶
The value channel.
Invariant: Value must be a float between 0.0 and 1.0, inclusive.
Methods¶
- HSV.glColor()¶
Converts thie color to an OpenGL value.
This conversion allows this object to be used by graphics libraries that depend on OpenGL (e.g. Kivy). The conversion first converts this object to the RGB color space.
- Returns
a 4 element list of the attributes in the range 0 to 1
- Return type
list
- HSV.webColor()¶
Converts this color to a web color string.
This conversion allows this object to be used by graphics libraries that depend on Tkinter (e.g. the drawing turtle). The conversion first converts this object to the RGB color space.
- Returns
a string representing a web color
- Return type
str
- HSV.rgba()¶
Converts this color to an rgba value.
This conversion allows this object to be used by graphics libraries that want integer color representation like PIL. The conversion first converts this object to the RGB color space.
- Returns
a 4 element tuple of the attributes in the range 0 to 255
- Return type
tuple