Welcome to ezcolors’s documentation!¶
This package contains a Color class to easily deal with colors
this module contains the definition of the color class a simple and easy to use class for anything colorful in all color spaces
- class ezcolors.Colors.Color(r: int = 0, g: int = 0, b: int = 0, a: int = 255, s: str = '', space: str = 'wiki', range: int = 255, name: Optional[str] = None, **kwargs)¶
Color class that can be constructed with either a string (hex value or color name), singular r, g and b values or a list/tuple of rgb/hsv/hsv values
- property a¶
The colors alpha channel
- property analagous¶
Returns a list of the color and its analagous colors
- property b¶
The colors Blue channel
- clamp()¶
ensures that r, g, b, a are within range
- closest(colors=16)¶
returns the closest color to self out of the supplied list. if no list is given it will default to the 16 terminal colors
- property compl¶
Returns the complementaru color
- distance(other)¶
returns the distance between two colors rgb values
- property g¶
The colors Green channel
- property h¶
The colors Hue in degrees 0-360
- property hex¶
returns the hexidecimal string of the color ignoring alpha
- property hex4¶
Returns a hexidecimal string of the color including the alpha channel
- property hsl¶
Calculates and returns Hue, Saturation, Luminosity from the colors RGB values
- property hsv¶
Calculates and returns Hue, Saturation, Value from the colors RGB values
- hsvgradient(target, steps)¶
Returns a list of colors from self to target of length steps that gradually blends through the hsv colorspace
- is_shade_of_white()¶
returns True if r == g == b
- property l¶
The colors luminosity in %, 0-100
- property name¶
gets the name of the color from the desired space
- property nphsl¶
returns the colors hsl values as a numpy array
- property nphsv¶
returns the colors hsv values as a numpy array
- property nprgb¶
returns the colors rgb values as a numpy array
- property nprgba¶
returns the colors rgba values as a numpy array
- palette(length=3, function=<function uniform_random>, **kwargs)¶
Returns a list of colors following a pattern created by the function
- property r¶
The colors Red channel
- random()¶
Used to define a random color with no arguments it’ll return a random colour with random r,g,b values alternatively you can give it a list of values of length 0-3 any value that is None not given will be randomly generated rgb= red, green, blue hsv= hue, saturation, value hsl= hue, saturation, luminosity eg Color.random(hsl = [345, 100] will return a random color with hue 345° saturation 100% and random luminosity
- property range¶
not fully implemented, range of rgba values default 0-255
- property rgb¶
returns a tuple of the colors r, g and b values
- property rgba¶
Returns a list of the colors r, g, b and a channels
- property s¶
The colors saturation in %, 0-100
- property split_compl¶
Returns list containing 3 colors [complement with hue rotated -90°, original color, comlement with hue rotated 30°]
- property tetradic¶
Returns a list of the color and its tetriadic harmonies
- text(text, rgb=None)¶
Returns a colored string using ansi escape sequences
- property triadic¶
Returns a list of the color and its triadic harmonies
- property v¶
The colors value or brightness in % 0-100
- ezcolors.Colors.ColoredException(text, cls=<class 'Exception'>, color=Color(255, 128, 128, 255))¶
Returns an Exception with colored text. text – the desired exception text cls – the exception class color – the color to use
if you want to only color the first part of the message just put the pipe character surrounded by spaces at the desired end of the color eg: raise ColoredException(“Red | white”, ValueError)
- ezcolors.Colors.avg_color(colors: list)¶
returns the average color of the list of colors given
- class ezcolors.Colors.cBool(true=True, *args, **kwargs)¶
A coloured boolean. works like a normal boolean but when printed it’ll be green or red depending on truth can also be used to represent None
- ezcolors.Colors.choice(prompt, choices=('yes', 'no'), short=True, return_choice=False, colors=(Color(128, 255, 128, 255), Color(255, 128, 128, 255), Color(255, 255, 128, 255), Color(128, 128, 255, 255), Color(255, 125, 255, 255), Color(128, 255, 255, 255)))¶
Input with predefined yes/no choices. short shortens it to y/n. prompt is the input prompt choices is an iterable containing the possible choices. default yes/no return choice is whether to return the choice as a string instead of the index colors is an iterable of colora to cycle throufh for the choices.
- ezcolors.Colors.load_colors(webf, namesf)¶
Load the color names from file
- ezcolors.Colors.string_to_color(string, space='wiki:')¶
returns a Color from a given hex value or color name
this module contains useful functions for converting between colorspaces
- ezcolors.utilities.hex_to_rgb(string)¶
convert hex to rgb
- ezcolors.utilities.hsl_to_hsv(h, s, l)¶
convert from hsv to hsl
- ezcolors.utilities.hsl_to_rgb(h, s, l, maximum=255)¶
convert from hsl to rgb
- ezcolors.utilities.hsv_to_hsl(h, s, v)¶
convert from hsv to hsl
- ezcolors.utilities.hsv_to_rgb(h, s, v, maximum=255)¶
convert from hsv to rgb
- ezcolors.utilities.rgb_to_hex(r, g, b)¶
convert rgb to hex
- ezcolors.utilities.rgb_to_hsl(r, g, b)¶
convert from rgb to hsl
- ezcolors.utilities.rgb_to_hsv(r, g, b, maximum=255)¶
convert from rgb to hsv
this module contains various color palette functions that are to be used with the Color().palette() function
- ezcolors.palettes.all(last, steps=16, **kwargs)¶
debug function that returns a list containing all available palettes for the color
- ezcolors.palettes.color_list(last, length=16, i=0, colorlist=None, **kwargs)¶
not sure if i still need this but havent deleted it in case it breaks everything
- ezcolors.palettes.golden_ratio(last, **kwargs)¶
produces a palette rotating each colors hue by the golden ratio. each color is high in contrast to the last
- ezcolors.palettes.rainbow(last, length=16, **kwargs)¶
produces a palette rotating the hue 360° gradually
- ezcolors.palettes.random_hsl(last, **kwargs)¶
random hue saturation and luminosity values. if h, s or l specified those values won’t be randomised
- ezcolors.palettes.random_hsv(last, **kwargs)¶
random hue saturation and value/brightness values. if h, s or v specified those values won’t be randomised
- ezcolors.palettes.random_offset(last, **kwargs)¶
produces a pelette of colors consisting of values + or - the given offset
- ezcolors.palettes.save(palette, path='./', file='SavedPallet', overwrite=True, **kwargs)¶
not fully implemented saves the color palette to a json file
- ezcolors.palettes.saveall(color, path='./', file='SavedPallet', overwrite=True, length=16, **kwargs)¶
not fully implemented saves all color palettes of a color to a json file
- ezcolors.palettes.shades(last, length=16, **kwargs)¶
produces a palette varying from the base color to black
- ezcolors.palettes.tints(last, length=16, **kwargs)¶
produces a palette varying from the base color to white
- ezcolors.palettes.tones(last, length=16, **kwargs)¶
produces a palette varying from the base color to grey
- ezcolors.palettes.uniform_random(last, **kwargs)¶
Random values for r,g,b this is the least harmonious palette as its completely random