WheelItem

Introduction

WheelItem is a dataclass to simplify handling of colorwheel definitions. The structure of data closely mirrors YAML definition file(s) used to define colors.

A Wheel Item simply contains a named RGB color sequence.

Naming the sequence is used for easy switching of colorwheels, while the list of colors is a list of ColorItem objects. See ColorItem for more information.

Specification

WheelItem: a dataclass containing one ColorWheel definition

The object contains the following values:

  • name: ColorWheel name. The name is used to retrieve a named color sequence

  • colors: List of ColorItem colors

WheelItem encapsulates a colorwheel selection and is used internally by colorwheels.

class colorwheels.wheel_item.WheelItem(name: str, colors: List[colorwheels.color_item.ColorItem])

Content of one colorwheel

classmethod complement_wheel_item(reference_wheel, name='')

Use the reference wheel to create a similar, but color complementing wheel item.

If no name is provided, uses original name with the ‘_complement’ suffix

from_float_list(color_list)

Convert a list of float RGB tuples to native format

This method comes in handy, if you use libraries like ‘Colour’ in your code.

The Colour library uses RGB float values, encoded in tuples ranging from 0.0-1.0. We convert these values to an int tuple, i.e. int values ranging from 0-255

Parameters

color_list – A list of colors in float format(0.0-1.0 for each segment)

generate_rainbow(size, amplitude, center, frequency)

Generate colors with a Rainbow palette. Overwrites colors list.

Uses a simplified algorithm.

Tip: If you don’t wish to experiment with the algorithm, you can decide on the rainbow size (number of colors), and use these values as a starting point:

amplitude=127, center=128, frequency=0.3

property is_single_color

Indicates, if color list contains only one color

classmethod rainbow_wheel_item(name, size, amplitude=127, center=128, frequency=0.3)

Generate a wheel item with a Rainbow palette. Provides some sensible defaults.