Colorwheels

Introduction

A Color management module, containing the Colorwheel generator. As described in the code documentation, the idea of the colorwheel is to choose a sequence of colors, and, by using a next call, select the next color in the chain. Then start at the beginning again.

Our generator allows to multiple return types. You can tweak the return values by setting a generator_type to any one of those values: "rgb_tuple", "rgba_tuple", or "hexadecimal". If calling standard next methods, 3 are provided for each mentioned type of return value.

Specification

Colorwheels is a module to generate color sequences. A Colorwheels instance contains multiple color wheel definitions and functions as a generator of color values in multiple formats. You can activate any available colorwheel anytime, to obtain different effects.

class colorwheels.colorwheels.Colorwheels(add_base_colors=True)

Base class for returning color sequences.

We represent colors similar to Color Wheels in photography, i.e. a sequence of colors is located on an imaginary wheel and endlessly served to applications in a given sequence.

Colorwheels can be generated or loaded from a YAML file. See documentation and examples.

__init__(add_base_colors=True)

Create Colorwheels instance.

wheel configurations is a ColorwheelsConfig object (singleton), which contains color definitions loaded from the environment, or generated by code.

A default configuration object is created (or inherited from other parts of the code).

activate_colorwheel(name)

Activates colorwheel by name, from configuration file. Sets active_wheel with new setting.

Raises

ValueError – Raises ValueError exception if name is not found

property active_colors

Color list of active colorwheel.

Exposes the active colorwheels color list for easy iteration

property active_name

Currently active colorwheel name

complement()

Use own colors to create a compementing color palette.

Current colors are overwritten.

Tip: to synchronize two colorwheels, create complements before using the generator(s)

See also

rainbow

You can also change the generator colors by creating a rainbow effect

next()

Get the next color from the ColorWheel as an RGB tuple

Returns

RGB tuple of next selected color. The returned value is an integer tuple representing a color, i.e. (r,g,b). Red would return (255,0,0)

Return type

tuple

See also

next_rgba

Get the next color from ColorWheel using RGBA

next_hex

Get the next color from ColorWheel as a hex string

next_hex()

Get the next color from ColorWheel as a hex string

Returns

hex string representation of RGB color

Return type

string

See also

next

Get the next color from the ColorWheel as an RGB tuple

next_rgba

Get the next color from ColorWheel using RGBA

next_rgba(alpha=255)

Get the next color from ColorWheel using RGBA

Returns

RGB tuple of next selected color. The returned value is an integer tuple representing a color, i.e. (r,g,b,a). Red would return (255,0,0,255) if alpha is default at 255

Return type

tuple

See also

next

Get the next color from the ColorWheel as an RGB tuple

next_hex

Get the next color from ColorWheel as a hex string

rainbow(size)

Generate rainbow color palette, using defaults.

Current colors are overwritten. A new, suitable name is generated.

Tip: to generate rainbow effects with more options, use the related rainbow class method from wheel_item

Parameters

size – number of rainbow colors to be generated

See also

complement

You can also change the generator colors by replacing current colors with complementing colors

set_generator_type(new_type)

Set the generator type to a value out of generator_types.

Raises

ValueError – Raises ValueError exception if new_type is not avaialble

property wheel_configurations

Returns the configuration object ColorwheelsConfig, used by Colorwheels

You can manage the configurations from any Colorwheels instance used in your program. Handle with care! The configurator is a singleton, i.e. if you for example load a different set of colors, all running generators will be affected.