package matrix

  1. Overview
  2. Docs

Module Color.PackedSource

Colors as immediate integers, for code that stores many colors, such as the planes of a grid.

A packed color is encode c. Its bit layout is private to this module, so code stores and compares packed colors and reads them only with these functions. The module requires a 64-bit platform (Sys.int_size >= 62).

Sourcetype color = t

The type for colors, Color.t.

Sourceval encode : color -> int

encode c is c packed.

Sourceval decode : int -> color

decode p is the color p packs. Bits outside those of a packed color are ignored, and an integer whose intent bits are invalid decodes to default_bg.

Sourceval red : int -> int
Sourceval green : int -> int
Sourceval blue : int -> int
Sourceval alpha : int -> int

red p, green p, blue p and alpha p are the components of the snapshot of p, in [0;255].

Sourceval red_f : int -> float
Sourceval green_f : int -> float
Sourceval blue_f : int -> float
Sourceval alpha_f : int -> float

red_f p, green_f p, blue_f p and alpha_f p are the components of the snapshot of p, in [0.0;1.0].

Sourceval intent : int -> intent

intent p is the intent of p.

Sourceval indexed_slot : int -> int

indexed_slot p is the palette entry of p when intent p is Indexed _, and meaningless otherwise.

Sourceval with_alpha : int -> int -> int

with_alpha p a is p with alpha a, clamped to [0;255], and the same RGB and intent.

Sourceval blend : src:int -> dst:int -> int

blend ~src ~dst is Color.blend ~src ~dst on packed colors. It allocates nothing.

Sourceval of_rgba_f : float -> float -> float -> float -> int

of_rgba_f r g b a is Color.of_rgba_f r g b a packed.