Color

Every color in the library, whether for text, a background, or a fill between clips, is a Color. There is one class and two ways to make one.

Two ways to name a color

By name, from the set of standard named colors:

from imaginaryarts import Color

Color(system="white")
Color(system="teal")
Color(system="DarkSlateGray")   # names are case-insensitive

By hex code, for an exact value:

Color(hex="#ab32a3")
Color(hex="ab32a3")      # the # is optional
Color(hex="0xab32a3")    # so is a 0x prefix

Pass exactly one of system or hex. Hex colors are rrggbb only, with no alpha channel; transparency is a property of the thing being drawn, such as TextStyle(opacity=0.7), not of the color.

Where colors are used

# The canvas color: fills gaps between visuals, and the fade at the very
# start and end of the video.
video = VideoBuilder(project=project, background=Color(system="black"))

# Text.
TextStyle(color=Color(system="white"))
TextStyle(color=Color(hex="#f2e8d5"))

The named colors

There are 140 named colors, the same set that CSS and ffmpeg use. A few you will reach for often:

whiteblackgraysilver
ivorybeigewheattan
goldorangecoraltomato
crimsonfirebrickmaroonnavy
royalbluesteelbluetealseagreen

The full list, with swatches, is on the ffmpeg color page.

A misspelled name raises an error that suggests the closest matches, so Color(system="grey") tells you it does not exist and offers gray.

Behind the scenes

Names are resolved to RGB values inside the library, before anything reaches the video encoder. That guarantees a named color means exactly the same thing on captions, on the background and in a fade, and it is why you can inspect a color in Python:

Color(system="teal").rgb    # (0, 128, 128)