Color class (csscolor.color)

The color class.

class csscolor.color.Color

An sRGB color.

RGBA values should be in the range 0.0 - 1.0. CSS and some other graphics tools use values in the range 0-255 for RGB, these can be returned with the .as_int_triple() method.

as_hex_string()

Returns the color in CSS hex formatr #xxxxxx.

Any transparency will be ignored.

as_hsl()

Returns the color as a h,s,l,a tuple with components between 0 and 1.

as_hsl_int_triple()

Returns the h, s, l triple with each value in the range 0-255.

Any transparency will be ignored.

as_hsl_percent_string()

Returns the color in CSS hsl format: hsl(h%, s%, l%).

Color channel values are in the range 0-100.

as_hsl_percent_triple()

Returns the h, s, l triple with each value in the range 0-100.

Any transparency will be ignored.

as_hsl_string()

Returns the color in CSS hsl format: hsl(h, s, l).

Color channel values are in the range 0-255.

as_hsla_percent_string()

Returns the color in CSS hsl format: hsla(h%, s%, l%, a).

Color channel values are in the range 0-100. Alpha is 0-1.

as_hsla_string()

Returns the color in CSS hsl format: hsla(h, s, l, a).

Color channel values are in the range 0-255. Alpha is 0-1.

as_int_triple()

Returns the r,g,b triple with each value in the range 0-255.

Any transparency will be ignored.

as_percent_triple()

Returns the r,g,b triple with each value an integer ≤ 100.

Any transparency will be ignored.

as_rgb24()

Returns the color as an RGB24 integer.

as_rgb_percent_string()

Returns the color in CSS rgb format: rgb(r%, g%, b%).

Color channel values are in the range 0-100.

as_rgb_string()

Returns the color in CSS rgb format: rgb(r, g, b).

Color channel values are in the range 0-255.

as_rgba_percent_string()

Returns the color in CSS rgb format: rgba(r%, g%, b%, a).

Color channel values are in the range 0-100. Alpha is 0-1.

as_rgba_string()

Returns the color in CSS rgb format: rgba(r, g, b, a).

Color channel values are in the range 0-255. Alpha is 0-1.