Class: Color

PSPDFKit.Color

Color objects are used in annotations for defining colors. We're using an rgb representation internally with the r, g, b values clipped between 0 and 255 inclusive.

It is an Immutable.Record and thus can be updated using set(key, value), for example: color.set("r", 255).

Constructor

new PSPDFKit.Color(args)

A simple RGB color value.

Parameters:
Name Type Description
args Object

An object used to initialize the color. If r, g or b is omitted, 0 will be used instead.

Default Value:
  • { r: 0, g: 0, b: 0 }
Example

Create and update a color

var color = new PSPDFKit.Color({ r: 245, g: 0, b: 0 });
color = color.set("r", 255);
color.r; // => 255

Extends

  • Immutable.Record

Members

Methods




Members

(static) BLACK: PSPDFKit.Color

Simple black (CSS: rgb(0, 0, 0))

Type:

(static) BLUE: PSPDFKit.Color

Blue (CSS: rgb(36, 131, 199))

Type:

(static) GREEN: PSPDFKit.Color

Green (CSS: rgb(110, 176, 0))

Type:

(static) LIGHT_BLUE: PSPDFKit.Color

Light blue (CSS: rgb(141, 184, 255))

Type:

(static) LIGHT_GREEN: PSPDFKit.Color

Light green (CSS: rgb(162, 250, 123))

Type:

(static) LIGHT_RED: PSPDFKit.Color

Light red (CSS: rgb(247, 141, 138))

Type:

(static) LIGHT_YELLOW: PSPDFKit.Color

Light yellow (CSS: rgb(252, 238, 124))

Type:

(static) ORANGE: PSPDFKit.Color

Orange (CSS: rgb(243, 149, 0))

Type:

(static) RED: PSPDFKit.Color

Red (CSS: rgb(248, 36, 0))

Type:

(static) WHITE: PSPDFKit.Color

Simple white (CSS: rgb(255, 255, 255))

Type:

b: number

The blue value of the color.

Type:
  • number
Default Value:
  • 0

g: number

The green value of the color.

Type:
  • number
Default Value:
  • 0

r: number

The red value of the color.

Type:
  • number
Default Value:
  • 0

Methods

darker(percent) → {Color}

Returns a darker version of the current Color.

Parameters:
Name Type Description
percent number

The percentage of lightness between 0 and 100.

Returns:

A Color with the new values.

Type
Color
Example
const color = PSPDFKit.Color.RED.darker(50);

equals(color) → {boolean}

Returns true if the provided color or object and the current Color have the same RGB values.

Parameters:
Name Type Description
color Color | Object

Color instance or RGB object.

Returns:

True if equal, false otherwise.

Type
boolean
Example
const color = PSPDFKit.Color.RED.equals({ r: 248, g: 36, b: 0 });

lighter(percent) → {Color}

Returns a lighter version of the current Color.

Parameters:
Name Type Description
percent number

The percentage of lightness between 0 and 100.

Returns:

A Color with the new values.

Type
Color
Example
const color = PSPDFKit.Color.RED.lighter(50);

toCSSValue() → {string}

Converts the color to a CSS value (e.g. rgb(255, 0, 0)).

Returns:

A CSS color value in rgb format.

Type
string
Example
PSPDFKit.Color.RED.toCSSValue(); // => 'rgb(248, 36, 0)'