Color

User Guide / Graphics

Prince supports RGB, RGBA, CMYK, and named spot colors.

RGB

RGB colors can be specified using the rgb() function syntax, shorthand hash notation, or with standard keywords. For example, red can be specified in three ways:

color: rgb(255, 0, 0)
color: #ff0000
color: red

RGBA

RGBA colors are equivalent to RGB plus an opacity (or alpha) value between 0 and 1. When the opacity is 0 the color is transparent, and when the opacity is 1 the color is identical to the RGB color.

color: rgba(255, 0, 0, 1)    // red
color: rgba(255, 0, 0, 0.5)  // translucent red
color: rgba(255, 0, 0, 0)    // fully transparent

CMYK

CMYK colors can be specified using the cmyk() function syntax:

color: cmyk(1, 0, 0, 0)  // cyan
color: cmyk(0, 1, 1, 0)  // red
color: cmyk(0, 0, 0, 1)  // black

Spot colors

Named spot colors can be defined using the @prince-color rule. An alternate RGB or CMYK color must also be specified using the alternate-color property. This will be used in situations where the named color is not available, such as when viewing the generated PDF file on a display.

@prince-color MyColor {
    alternate-color: rgb(255,0,0)
}

Spot colors can be used with a specified tint value between 0 and 1, which defaults to 1. They can also enable overprint:

color: prince-color(MyColor)                  // tint 1.0
color: prince-color(MyColor, 0.5)             // tint 0.5
color: prince-color(MyColor, overprint)       // tint 1.0, overprint
color: prince-color(MyColor, 0.5, overprint)  // tint 0.5, overprint