ColorMap

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.pitch" { graph [label="abjad.pitch"]; node [color=1]; "abjad.pitch.ColorMap.ColorMap" [URL="../api/abjad/pitch/ColorMap.html#abjad.pitch.ColorMap.ColorMap", color=black, fontcolor=white, label="Color\nMap", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/pitch/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/pitch/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.pitch.ColorMap.ColorMap"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.pitch.ColorMap.ColorMap(*, colors=None, pitch_iterables=None)

Color map.

Maps pitch-classes to red, green and blue:

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> abjad.f(color_map)
abjad.ColorMap(
    colors=['red', 'green', 'blue'],
    pitch_iterables=[
        [-8, 2, 10, 21],
        [0, 11, 32, 41],
        [15, 25, 42, 43],
        ],
    )

Color maps are immutable.


Attributes Summary

__format__ Formats color map.
__getitem__ Gets pitch_class color.
colors Gets colors.
get Gets key from color map.
is_twelve_tone_complete Is true when color map contains all 12-ET pitch-classes.
is_twenty_four_tone_complete Is true when color map contains all 24-ET pitch-classes.
pairs Gets pairs.
pitch_iterables Gets pitch iterables.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

__format__(format_specification='')

Formats color map.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> abjad.f(color_map)
abjad.ColorMap(
    colors=['red', 'green', 'blue'],
    pitch_iterables=[
        [-8, 2, 10, 21],
        [0, 11, 32, 41],
        [15, 25, 42, 43],
        ],
    )

Returns string.

__getitem__(pitch_class)

Gets pitch_class color.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> color_map[11]
'green'

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Methods

get(key, alternative=None)

Gets key from color map.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> color_map.get(11)
'green'

Returns alternative when key is not found.

Returns string.


Read-only properties

colors

Gets colors.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> color_map.colors
['red', 'green', 'blue']

Returns list.

is_twelve_tone_complete

Is true when color map contains all 12-ET pitch-classes.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> color_map.is_twelve_tone_complete
True

Return boolean.

is_twenty_four_tone_complete

Is true when color map contains all 24-ET pitch-classes.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> color_map.is_twenty_four_tone_complete
False

Return boolean.

pairs

Gets pairs.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> for pair in color_map.pairs:
...     pair
...
(0, 'green')
(1, 'blue')
(2, 'red')
(3, 'blue')
(4, 'red')
(5, 'green')
(6, 'blue')
(7, 'blue')
(8, 'green')
(9, 'red')
(10, 'red')
(11, 'green')

Returns list.

pitch_iterables

Gets pitch iterables.

>>> color_map = abjad.ColorMap(
...     colors=['red', 'green', 'blue'],
...     pitch_iterables=[
...         [-8, 2, 10, 21],
...         [0, 11, 32, 41],
...         [15, 25, 42, 43],
...         ],
...     )
>>> color_map.pitch_iterables
[[-8, 2, 10, 21], [0, 11, 32, 41], [15, 25, 42, 43]]

Returns list.