Skip to content

Types

Common Lens types

Color

ts
type Color = readonly [number, number, number, number];

Color type.

Array of 4 elements representing color channel values: [red, green, blue, alpha]

Each channel value must be in range [0; QuantumRange], where QuantumRange is maximal channel value, which depends on color depth and generally equals 255 for 8 bits per channel color depth, unless underlying image interface supports bigger values. Alpha channel equals 0 for completely transparent color and QuantumRange (255 for 8 bits per channel) for fully opaque color.

Point

ts
type Point = [number, number];

Tuple of X and Y coordinates.

ViewportLiteral

ts
type ViewportLiteral =
  | { x1: number; y1: number; x2: number; y2: number }
  | { width: number; height: number; x?: number; y?: number };

Describes image virtual viewport. Used only for creating Viewport class instance.

Can be defined in two forms:

  • {x1, y1, x2, y2}, where x1, x2 are coordinates of top-left apex image pixel, and x2, y2 are coordinates of bottom-right apex image pixel.
  • {width, height, x?, y?}, where width, height are image viewport width and height, and x, y are optional origin offset coordinates.

INFO

Virtual viewport coordinates and image pixel coordinates are not the same. Image pixel coordinates always are: x[0,width1],y[0,height1] And virtual viewport coordinates may be any values.

See Virtual Viewport