ColorwheelsConfig

Introduction

ColorWheelConfig is a configuration helper for Colorwheels

Specification

ColorwheelsConfig is a configuration helper for Colorwheels, implemented as a singleton.

The helper loads a configuration YAML file and serves the colors by name to a Colorwheels generator.

class colorwheels.colorwheels_config.ColorwheelsConfig(*args, **kwargs)

Configuration helper for Colorwheels.

__init__()

Initialize configuration helper for Colorwheels.

The constructor creates the most simple configuration, and we expect a configuration file to be loaded later by code.

The initial wheel available is a primitive with ‘red’, ‘green’, ‘blue’, under the wheel name ‘default’. This is equivalent to an RGB definition.

add_base_colors()

This method adds base colors to the list of available colors in colorwheels, to ensure availability of often used colors.

These simple color sequences have only one color available, so running the generator returns the same color all over again. It can come in handy for example, if you have 2 colorwheels for foreground/background, and want to have the background defaulting to black only ….

The method adds the following one-color named wheels:

‘red’, ‘green’, ‘blue’, ‘cyan’, ‘magenta’, ‘yellow’, ‘black’, ‘white’

add_wheel_item(item)

Adds a WheelItem to definitions list.

Parameters

item – A WheelItem object, which should be added to global configurations

Raises

ValueError – Raises error if item name already exists

create_wheel_item(name, colors)

Create a WheelItem from parts. Function returns the created item

Parameters
find_wheel(name)

Find wheelitem by name. None if not found

property first_wheel

Get the first wheel available

load_wheels(filename, add_base_colors=True)

loads YAML color definition file. The loaded file is converted to a list of WheelItem objects.

When loading a new definition from YAML, make sure colorwheels activates whatever wheel is required!

Parameters

filename (filename of file containing color definitions in YAML format. See) – YAML Color Definitions for more details

Raises
  • FileNotFoundError: – If file is not found on system

  • YAMLError: – If file is a wrongly formatted YAML file

property wheel_names

Return list of wheel names available in configuration