---
title: 'Color chaining'
description: 'How color-related transformations, overlays and masks interact.'
category: 'reference'
position: 4
---

# Color chaining

> How color-related transformations, overlays and masks interact.

TwicPics provides seven color-related transformations:

- three direct coloring transformations:
  - [background](/docs/reference/transformations#background)
  - [border](/docs/reference/transformations#border)
  - [colorize](/docs/reference/transformations#colorize)
- four colorblindness filters:
  - [achromatopsia](/docs/reference/transformations#achromatopsia)
  - [deuteranopia](/docs/reference/transformations#deuteranopia)
  - [protanopia](/docs/reference/transformations#protanopia)
  - [tritanopia](/docs/reference/transformations#colorize)

In addition, it is possible to add both a [mask](/docs/essentials/path-configuration#mask) and an [overlay](/docs/essentials/path-configuration#overlay) in your [path configuration](/docs/essentials/path-configuration).

## Direct coloring transformations

Like any other transformation in the TwicPics API, the order of [background](/docs/reference/transformations#background), [border](/docs/reference/transformations#border), and [colorize](/docs/reference/transformations#colorize) transformations in your manipulation is respected:

- `border=red/colorize=monochrome` will colorize the given [border](/docs/reference/transformations#border) and the end result will be a dark gray border color,
- `colorize=monochrome/border=red` will not colorize the given [border](/docs/reference/transformations#border) because it's specified __after__ the [colorize](/docs/reference/transformations#colorize) transformation and thus, the end result will be a red border color.

Same goes for the [background](/docs/reference/transformations#background) transformation.

Multiple [colorize](/docs/reference/transformations#colorize) transformations will be applied in order.

## Mask

Translucency created by the [mask](/docs/essentials/path-configuration#mask) is considered as _border_ and will be filled with:

- the end [border](/docs/reference/transformations#border) color if provided,
- otherwise the end [background](/docs/reference/transformations#border) color if provided,
- otherwise it will simply stay translucent.

## Overlay

The [overlay](/docs/essentials/path-configuration#overlay) is added after:

- any direct coloring transformation ([background](/docs/reference/transformations#background), [border](/docs/reference/transformations#border), and [colorize](/docs/reference/transformations#colorize)) has been applied,
- and the [mask](/docs/essentials/path-configuration#mask) has been applied.

The [overlay](/docs/essentials/path-configuration#overlay) is thus immune to colorization and masking.

## Colorblindness filters

Colorblindness filters ([achromatopsia](/docs/reference/transformations#achromatopsia), [deuteranopia](/docs/reference/transformations#deuteranopia), [protanopia](/docs/reference/transformations#protanopia), and [tritanopia](/docs/reference/transformations#colorize)) are _"global"_ and applied at the very end of our image processing process, so after:

- every [background](/docs/reference/transformations#background), [border](/docs/reference/transformations#border), and [colorize](/docs/reference/transformations#colorize) transformation has been applied,
- the [mask](/docs/essentials/path-configuration#mask) has been applied,
- and the [overlay](/docs/essentials/path-configuration#overlay) has been added in.
