colorviews package¶
Submodules¶
colorviews.colors module¶
Classes to represent colors with and without alpha value.
Color represents color values without alpha and AlphaColor represents color values that have alpha.
-
class
colorviews.colors.
BaseColor
(r: float, g: float, b: float)¶ Bases:
object
Base class of all Color classes.
-
class
colorviews.colors.
Color
(r: float, g: float, b: float)¶ Bases:
colorviews.colors.BaseColor
Class representing colors without alpha value.
Information is stored using rgb values.
-
property
rgb
¶ RGB colorview as float values
-
property
hsl
¶ HSL colorview as float values
-
property
hsv
¶ HSV colorview as float values
-
property
rgb_
¶ RGB colorview as int values
-
property
hsl_
¶ HSL colorview as int values
-
property
hsv_
¶ HSV colorview as int values
-
classmethod
from_name
(name: str) → colorviews.colors.Color¶ Creates a Color object based on the given color name.
Only CSS3 extended color keyword names are recognized.
- Parameters
name – Name of color.
- Returns
Color object with value corresponding to the given color name.
-
classmethod
from_int
(value: int) → colorviews.colors.Color¶ Creates a Color object from the given integer color value.
- Parameters
value – Integer color value.
- Returns
Color object with given integer value.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgb
(r: float, g: float, b: float) → colorviews.colors.Color¶ Creates a Color object from the given RGB float values.
- Parameters
r – Red component of RGB value as a float in the range [0.0, 1.0]
g – Green component of RGB value as a float in the range [0.0, 1.0]
b – Blue component of RGB value as a float in the range [0.0, 1.0]
- Returns
Color object with given RGB values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsl
(h: float, s: float, l: float) → colorviews.colors.Color¶ Creates a Color object from the given HSL float values.
- Parameters
h – Hue component of HSL value as a float in the range [0.0, 1.0]
s – Saturation component of HSL value as a float in the range [0.0, 1.0]
l – Lightness component of HSL value as a float in the range [0.0, 1.0]
- Returns
Color object with given HSL values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsv
(h: float, s: float, v: float) → colorviews.colors.Color¶ Creates a Color object from the given HSV float values.
- Parameters
h – Hue component of HSV value as a float in the range [0.0, 1.0]
s – Saturation component of HSV value as a float in the range [0.0, 1.0]
v – Value component of HSV value as a float in the range [0.0, 1.0]
- Returns
Color object with given HSV values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_rgb_
(r: int, g: int, b: int) → colorviews.colors.Color¶ Creates a Color object from the given RGB unsigned int values.
- Parameters
r – Red component of RGB value as an int in the range [0, 255]
g – Green component of RGB value as an int in the range [0, 255]
b – Blue component of RGB value as an int in the range [0, 255]
- Returns
Color object with given RGB values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsl_
(h: int, s: int, l: int) → colorviews.colors.Color¶ Creates a Color object from the given HSL int values.
- Parameters
h – Hue component of HSL value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSL value as an int in the range [0, 100]
l – Lightness component of HSL value as an int in the range [0, 100]
- Returns
Color object with given HSL values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsv_
(h: int, s: int, v: int) → colorviews.colors.Color¶ Creates a Color object from the given HSV int values.
- Parameters
h – Hue component of HSV value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSV value as an int in the range [0, 100]
v – Value component of HSV value as an int in the range [0, 100]
- Returns
Color object with given HSV values.
- Raises
ValueError – If any argument is outside valid range.
-
copy
() → colorviews.colors.Color¶ Creates a copy of the Color object.
- Returns
An identical copy of the Color object.
-
property
-
class
colorviews.colors.
AlphaColor
(r: float, g: float, b: float, a: float)¶ Bases:
colorviews.colors.BaseColor
Class representing colors with alpha value.
Information is stored using rgba values.
-
property
rgba
¶ RGBA colorview as float values
-
property
hsla
¶ HSLA colorview as float values
-
property
hsva
¶ HSVA colorview as float values
-
property
rgba_
¶ RGBA colorview as int values
-
property
hsla_
¶ HSLA colorview as int values
-
property
hsva_
¶ HSVA colorview as int values
-
classmethod
from_name
(name: str, a: float = 0.0) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object based on the given color name.
Only CSS3 extended color keyword names are recognized.
- Parameters
name – Name of color.
a – Alpha value of color as a float in the range [0.0, 1.0]. Default value is 0.0
- Returns
AlphaColor object with value corresponding to the given color name and alpha value.
-
classmethod
from_int
(value: int) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given integer color value.
- Parameters
value – Integer color value.
- Returns
AlphaColor object with given integer value.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgba
(r: float, g: float, b: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given RGBA float values.
- Parameters
r – Red component of RGBA value as a float in the range [0.0, 1.0].
g – Green component of RGBA value as a float in the range [0.0, 1.0].
b – Blue component of RGBA value as a float in the range [0.0, 1.0].
a – Alpha component of RGBA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given RGBA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsla
(h: float, s: float, l: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSLA float values.
- Parameters
h – Hue component of HSLA value as a float in the range [0.0, 1.0]
s – Saturation component of HSLA value as a float in the range [0.0, 1.0].
l – Lightness component of HSLA value as a float in the range [0.0, 1.0].
a – Alpha component of HSLA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given HSLA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsva
(h: float, s: float, v: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSVA float values.
- Parameters
h – Hue component of HSVA value as a float in the range [0.0, 1.0]
s – Saturation component of HSVA value as a float in the range [0.0, 1.0].
v – Value component of HSVA value as a float in the range [0.0, 1.0].
a – Alpha component of HSVA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given HSVA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgba_
(r: int, g: int, b: int, a: int) → colorviews.colors.AlphaColor¶ Creates a AlphaColor object from the given RGBA int values.
- Parameters
r – Red component of RGBA value as an int in the range [0, 255]
g – Green component of RGBA value as an int in the range [0, 255]
b – Blue component of RGBA value as an int in the range [0, 255]
a – Alpha component of RGBA value as an int in the range [0, 100]
- Returns
AlphaColor object with given RGBA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsla_
(h: int, s: int, l: int, a: int) → colorviews.colors.AlphaColor¶ Creates a AlphaColor object from the given HSLA int values.
- Parameters
h – Hue component of HSLA value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSLA value as an int in the range [0, 100]
l – Lightness component of HSLA value as an int in the range [0, 100]
a – Alpha component of HSVA value as a float in the range [0, 100].
- Returns
AlphaColor object with given HSLA values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsva_
(h: float, s: float, v: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSVA int values.
- Parameters
h – Hue component of HSVA value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSVA value as an int in the range [0, 100]
v – Value component of HSVA value as an int in the range [0, 100]
a – Alpha component of HSVA value as a float in the range [0, 100].
- Returns
AlphaColor object with given HSVA values.
- Raises
ValueError – If any value is outside the valid range.
-
copy
() → colorviews.colors.AlphaColor¶ Creates a copy of the AlphaColor object.
- Returns
An identical copy of the AlphaColor object.
-
property
colorviews.names module¶
Dictionary of CSS3 extended color keyword names.
Source: https://www.w3.org/wiki/CSS3/Color/Extended_color_keywords
colorviews.utils module¶
Utility functions to help other modules.
-
colorviews.utils.
validate
(val: float) → None¶ Check if val is between 0.0 and 1.0, including the limits.
- Parameters
val – Value to be validated.
- Raises
ValueError – If val is not in the range [0.0, 1.0].
-
colorviews.utils.
validate_uint
(val: float) → int¶
-
colorviews.utils.
validate_cent
(val: float) → int¶
-
colorviews.utils.
validate_float_angle
(val: float) → float¶
-
colorviews.utils.
validate_angle
(val: float) → int¶
-
colorviews.utils.
scale
(val: float, factor: int) → int¶ Multiply val with factor and convert result to an integer with proper rounding.
- Parameters
val – Float value to rounded
factor – Value with which val is multiplied.
- Returns
Rounded integer value of the product of val and factor.
colorviews.views module¶
ColorView classes for Color and AlphaColor objects
-
class
colorviews.views.
BaseColorView
(color: colors.BaseColor)¶ Bases:
object
Base class of all ColorView classes.
-
color
¶ Color whose view is being handled.
-
color
¶
-
-
class
colorviews.views.
BaseAlphaColorView
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of all float color view classes having alpha value.
-
property
a
¶ Alpha component as a float value
-
property
-
class
colorviews.views.
BaseAlphaColorView_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of all rounded int color view classes having alpha value.
-
property
a
¶ Alpha component as an int value
-
property
-
class
colorviews.views.
BaseColorViewRGB_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of ColorViewRGB_ and ColorViewRGBA_ classes.
-
property
r
¶ Red component as an int value
-
property
g
¶ Green component as an int value
-
property
b
¶ Blue component as an int value
-
property
-
class
colorviews.views.
ColorViewRGB_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewRGB_
Rounded int RGB view of Color objects.
-
property
vals
¶ Tuple of RGB values as ints.
-
replace
(r=None, g=None, b=None) → colors.Color¶ Create a new Color object by replacing the RGB values (as ints) of the Color object associated with the colorview.
- Parameters
r – Red component of RGB value as an int in the range [0, 255]
g – Green component of RGB value as an int in the range [0, 255]
b – Blue component of RGB value as an int in the range [0, 255]
- Returns
Color object with modified RGB values.
-
property
-
class
colorviews.views.
ColorViewRGBA_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewRGB_
,colorviews.views.BaseAlphaColorView_
Rounded int RGBA view of AlphaColor objects.
-
property
vals
¶ Tuple of RGBA values as ints.
-
replace
(r=None, g=None, b=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the RGBA values (as ints) of the AlphaColor object associated with the colorview.
- Parameters
r – Red component of RGBA value as an int in the range [0, 255]
g – Green component of RGBA value as an int in the range [0, 255]
b – Blue component of RGBA value as an int in the range [0, 255]
a – Alpha component of RGBA value as an int in the range [0, 100]
- Returns
AlphaColor object with modified RGBA values.
-
property
-
class
colorviews.views.
BaseColorViewRGB
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of ColorViewRGB and ColorViewRGBA classes.
-
property
r
¶ Red component as a float value
-
property
g
¶ Green component as a float value
-
property
b
¶ Blue component as a float value
-
property
-
class
colorviews.views.
ColorViewRGB
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewRGB
RGB view of Color objects in float values
-
property
vals
¶ Tuple of RGB values as floats.
-
replace
(r=None, g=None, b=None) → colors.Color¶ Create a new Color object by replacing the RGB values of the Color object associated with the colorview.
- Parameters
r – Red component of RGB value as a float in the range [0, 0.1].
g – Green component of RGB value as a float in the range [0, 0.1].
b – Blue component of RGB value as a float in the range [0, 0.1].
- Returns
Color object with modified RGB values.
-
property
-
class
colorviews.views.
ColorViewRGBA
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewRGB
,colorviews.views.BaseAlphaColorView
RGBA view of Color objects in float values
-
property
vals
¶ Tuple of RGBA values as floats.
-
replace
(r=None, g=None, b=None, a=None) → colors.AlphaColor¶ Create a new Color object by replacing the RGBA values of the Color object associated with the colorview.
- Parameters
r – Red component of RGBA value as a float in the range [0, 0.1].
g – Green component of RGBA value as a float in the range [0, 0.1].
b – Blue component of RGBA value as a float in the range [0, 0.1].
a – Alpha component of RGBA value as a float in the range [0, 0.1].
- Returns
Color object with modified RGBA values.
-
property
-
class
colorviews.views.
BaseColorViewHSL_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of ColorViewHSL_ and ColorViewHSLA_ classes.
-
property
h
¶ Hue component as an int value
-
property
s
¶ Saturation component as an int value
-
property
l
¶ Lightness component as an int value
-
property
-
class
colorviews.views.
ColorViewHSL_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSL_
Rounded int HSL view of Color objects.
-
property
vals
¶ Tuple of HSL values as ints.
-
replace
(h=None, s=None, l=None) → colors.Color¶ Create a new Color object by replacing the HSL values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSL value as an int. Resultant value will be h modulo 360.
s – Saturation component of HSL value as an int in the range [0, 100].
l – Lightness component of HSL value as an int in the range [0, 100].
- Returns
Color object with modified HSL values.
-
property
-
class
colorviews.views.
ColorViewHSLA_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSL_
,colorviews.views.BaseAlphaColorView_
Rounded int HSLA view of AlphaColor objects.
-
property
vals
¶ Tuple of HSLA values as ints.
-
replace
(h=None, s=None, l=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSLA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSLA value as a float. Resultant value will be h modulo 360
s – Saturation component of HSLA value as a float in the range [0, 100].
l – Lightness component of HSLA value as a float in the range [0, 100].
a – Alpha component of HSLA value as a float in the range [0, 100].
- Returns
AlphaColor object with modified HSLA values.
-
property
-
class
colorviews.views.
BaseColorViewHSL
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of ColorViewHSL and ColorViewHSLA classes.
-
property
h
¶ Hue component as a float value
-
property
s
¶ Saturation component as a float value
-
property
l
¶ Lightness component as a float value
-
property
-
class
colorviews.views.
ColorViewHSL
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSL
HSL view of Color objects in float values
-
property
vals
¶ Tuple of HSL values as floats.
-
replace
(h=None, s=None, l=None) → colors.Color¶ Create a new Color object by replacing the HSL values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSL value as a float. Resultant value will be h modulo 1.0
s – Saturation component of HSL value as a float in the range [0, 0.1].
l – Lightness component of HSL value as a float in the range [0, 0.1].
- Returns
Color object with modified HSL values.
-
property
-
class
colorviews.views.
ColorViewHSLA
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSL
,colorviews.views.BaseAlphaColorView
HSLA view of Color objects in float values
-
property
vals
¶ Tuple of HSLA values as floats.
-
replace
(h=None, s=None, l=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSLA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSLA value as a float. Resultant value will be h modulo 1.0
s – Saturation component of HSLA value as a float in the range [0, 0.1].
l – Lightness component of HSLA value as a float in the range [0, 0.1].
a – Alpha component of HSLA value as a float in the range [0, 0.1].
- Returns
AlphaColor object with modified HSLA values.
-
property
-
class
colorviews.views.
BaseColorViewHSV_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of ColorViewHSV_ and ColorViewHSVA_ classes.
-
property
h
¶ Hue component as an int value
-
property
s
¶ Saturation component as an int value
-
property
v
¶ Value component as an int value
-
property
-
class
colorviews.views.
ColorViewHSV_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSV_
Rounded int HSV view of Color objects.
-
property
vals
¶ Tuple of HSV values as ints.
-
replace
(h=None, s=None, v=None) → colors.Color¶ Create a new Color object by replacing the HSV values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSV value as an int. Resultant value will be h modulo 360.
s – Saturation component of HSV value as an int in the range [0, 100].
v – Value component of HSV value as an int in the range [0, 100].
- Returns
Color object with modified HSV values.
-
property
-
class
colorviews.views.
ColorViewHSVA_
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSV_
,colorviews.views.BaseAlphaColorView_
Rounded integer HSVA view of AlphaColor objects.
-
property
vals
¶ Tuple of HSVA values as ints.
-
replace
(h=None, s=None, v=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSVA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSVA value as an int. Resultant value will be h modulo 360.
s – Saturation component of HSVA value as an int in the range [0, 100].
v – Value component of HSVA value as an int in the range [0, 100].
a – Alpha component of HSVA value as an int in the range [0, 100].
- Returns
AlphaColor object with modified HSVA values.
-
property
-
class
colorviews.views.
BaseColorViewHSV
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorView
Base class of ColorViewHSV and ColorViewHSVA classes.
-
property
h
¶ Hue component as a float value
-
property
s
¶ Saturation component as a float value
-
property
v
¶ Value component as a float value
-
property
-
class
colorviews.views.
ColorViewHSV
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSV
HSV view of Color objects in float values
-
property
vals
¶ Tuple of HSV values as floats.
-
replace
(h=None, s=None, v=None) → colors.Color¶ Create a new Color object by replacing the HSV values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSV value as a float in the range [0, 0.1].
s – Saturation component of HSV value as a float in the range [0, 0.1].
v – Value component of HSV value as a float in the range [0, 0.1].
- Returns
Color object with modified HSV values.
-
property
-
class
colorviews.views.
ColorViewHSVA
(color: colors.BaseColor)¶ Bases:
colorviews.views.BaseColorViewHSV
,colorviews.views.BaseAlphaColorView
HSVA view of Color objects in float values
-
property
vals
¶ Tuple of HSVA values as floats.
-
replace
(h=None, s=None, v=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSVA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSVA value as a float in the range [0, 0.1].
s – Saturation component of HSVA value as a float in the range [0, 0.1].
v – Value component of HSVA value as a float in the range [0, 0.1].
a – Alpha component of HSVA value as a float in the range [0, 0.1].
- Returns
AlphaColor object with modified HSVA values.
-
property
Module contents¶
colorviews module
-
class
colorviews.
Color
(r: float, g: float, b: float)¶ Bases:
colorviews.colors.BaseColor
Class representing colors without alpha value.
Information is stored using rgb values.
-
property
rgb
¶ RGB colorview as float values
-
property
hsl
¶ HSL colorview as float values
-
property
hsv
¶ HSV colorview as float values
-
property
rgb_
¶ RGB colorview as int values
-
property
hsl_
¶ HSL colorview as int values
-
property
hsv_
¶ HSV colorview as int values
-
classmethod
from_name
(name: str) → colorviews.colors.Color¶ Creates a Color object based on the given color name.
Only CSS3 extended color keyword names are recognized.
- Parameters
name – Name of color.
- Returns
Color object with value corresponding to the given color name.
-
classmethod
from_int
(value: int) → colorviews.colors.Color¶ Creates a Color object from the given integer color value.
- Parameters
value – Integer color value.
- Returns
Color object with given integer value.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgb
(r: float, g: float, b: float) → colorviews.colors.Color¶ Creates a Color object from the given RGB float values.
- Parameters
r – Red component of RGB value as a float in the range [0.0, 1.0]
g – Green component of RGB value as a float in the range [0.0, 1.0]
b – Blue component of RGB value as a float in the range [0.0, 1.0]
- Returns
Color object with given RGB values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsl
(h: float, s: float, l: float) → colorviews.colors.Color¶ Creates a Color object from the given HSL float values.
- Parameters
h – Hue component of HSL value as a float in the range [0.0, 1.0]
s – Saturation component of HSL value as a float in the range [0.0, 1.0]
l – Lightness component of HSL value as a float in the range [0.0, 1.0]
- Returns
Color object with given HSL values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsv
(h: float, s: float, v: float) → colorviews.colors.Color¶ Creates a Color object from the given HSV float values.
- Parameters
h – Hue component of HSV value as a float in the range [0.0, 1.0]
s – Saturation component of HSV value as a float in the range [0.0, 1.0]
v – Value component of HSV value as a float in the range [0.0, 1.0]
- Returns
Color object with given HSV values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_rgb_
(r: int, g: int, b: int) → colorviews.colors.Color¶ Creates a Color object from the given RGB unsigned int values.
- Parameters
r – Red component of RGB value as an int in the range [0, 255]
g – Green component of RGB value as an int in the range [0, 255]
b – Blue component of RGB value as an int in the range [0, 255]
- Returns
Color object with given RGB values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsl_
(h: int, s: int, l: int) → colorviews.colors.Color¶ Creates a Color object from the given HSL int values.
- Parameters
h – Hue component of HSL value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSL value as an int in the range [0, 100]
l – Lightness component of HSL value as an int in the range [0, 100]
- Returns
Color object with given HSL values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsv_
(h: int, s: int, v: int) → colorviews.colors.Color¶ Creates a Color object from the given HSV int values.
- Parameters
h – Hue component of HSV value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSV value as an int in the range [0, 100]
v – Value component of HSV value as an int in the range [0, 100]
- Returns
Color object with given HSV values.
- Raises
ValueError – If any argument is outside valid range.
-
copy
() → colorviews.colors.Color¶ Creates a copy of the Color object.
- Returns
An identical copy of the Color object.
-
property
-
class
colorviews.
AlphaColor
(r: float, g: float, b: float, a: float)¶ Bases:
colorviews.colors.BaseColor
Class representing colors with alpha value.
Information is stored using rgba values.
-
property
rgba
¶ RGBA colorview as float values
-
property
hsla
¶ HSLA colorview as float values
-
property
hsva
¶ HSVA colorview as float values
-
property
rgba_
¶ RGBA colorview as int values
-
property
hsla_
¶ HSLA colorview as int values
-
property
hsva_
¶ HSVA colorview as int values
-
classmethod
from_name
(name: str, a: float = 0.0) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object based on the given color name.
Only CSS3 extended color keyword names are recognized.
- Parameters
name – Name of color.
a – Alpha value of color as a float in the range [0.0, 1.0]. Default value is 0.0
- Returns
AlphaColor object with value corresponding to the given color name and alpha value.
-
classmethod
from_int
(value: int) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given integer color value.
- Parameters
value – Integer color value.
- Returns
AlphaColor object with given integer value.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgba
(r: float, g: float, b: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given RGBA float values.
- Parameters
r – Red component of RGBA value as a float in the range [0.0, 1.0].
g – Green component of RGBA value as a float in the range [0.0, 1.0].
b – Blue component of RGBA value as a float in the range [0.0, 1.0].
a – Alpha component of RGBA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given RGBA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsla
(h: float, s: float, l: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSLA float values.
- Parameters
h – Hue component of HSLA value as a float in the range [0.0, 1.0]
s – Saturation component of HSLA value as a float in the range [0.0, 1.0].
l – Lightness component of HSLA value as a float in the range [0.0, 1.0].
a – Alpha component of HSLA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given HSLA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsva
(h: float, s: float, v: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSVA float values.
- Parameters
h – Hue component of HSVA value as a float in the range [0.0, 1.0]
s – Saturation component of HSVA value as a float in the range [0.0, 1.0].
v – Value component of HSVA value as a float in the range [0.0, 1.0].
a – Alpha component of HSVA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given HSVA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgba_
(r: int, g: int, b: int, a: int) → colorviews.colors.AlphaColor¶ Creates a AlphaColor object from the given RGBA int values.
- Parameters
r – Red component of RGBA value as an int in the range [0, 255]
g – Green component of RGBA value as an int in the range [0, 255]
b – Blue component of RGBA value as an int in the range [0, 255]
a – Alpha component of RGBA value as an int in the range [0, 100]
- Returns
AlphaColor object with given RGBA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsla_
(h: int, s: int, l: int, a: int) → colorviews.colors.AlphaColor¶ Creates a AlphaColor object from the given HSLA int values.
- Parameters
h – Hue component of HSLA value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSLA value as an int in the range [0, 100]
l – Lightness component of HSLA value as an int in the range [0, 100]
a – Alpha component of HSVA value as a float in the range [0, 100].
- Returns
AlphaColor object with given HSLA values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsva_
(h: float, s: float, v: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSVA int values.
- Parameters
h – Hue component of HSVA value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSVA value as an int in the range [0, 100]
v – Value component of HSVA value as an int in the range [0, 100]
a – Alpha component of HSVA value as a float in the range [0, 100].
- Returns
AlphaColor object with given HSVA values.
- Raises
ValueError – If any value is outside the valid range.
-
copy
() → colorviews.colors.AlphaColor¶ Creates a copy of the AlphaColor object.
- Returns
An identical copy of the AlphaColor object.
-
property