Module Color_brewery

Colors palettes and functions to brew colors.

version
0.2
type rgba = Gg.color

A RGBA color.

type cmyk = Gg.v4

A CMYK color.

val to_int : rgba -> int

to_int c converts the color to 0xRRGGBB where RR, GG and BB are the red, green and blue values expressed on 2 hexadecimal digits. The alpha value is ignored. This is convenient to interact, say, with the Graphics module.

val of_int_exn : ?⁠a:float -> int -> rgba

of_int_exn i returns the color provided as 0xRRGGBB.

raises Invalid_argument

if i does not represent a color.

parameter a

the transparency component of the color. Default: 0.

val of_int : ?⁠a:float -> int -> rgba option

of_int is the similar to of_int_exn except that it returns None instead of raising an exception.

val to_string : rgba -> string

to_string c converts the color to a string of the form #RRGGBB.

val to_gray : rgba -> rgba

to_gray c returns the grayscale color corresponding to c. It is a weighted sum of RGB Rec. ITU-R T.601-7 0.299 r + 0.587 g + 0.114 b.

“Continuous” color ranges

val hue : float -> rgba

hue h return the color corresponding to the hue h ∈ [0., 360.).

val hue_pct : float -> rgba

hue h return the color corresponding to the hue h ∈ [0., 1.).

module Gradient : sig ... end
val range : ?⁠grad:Gradient.t -> n:int -> float -> float -> (float * rgba) list

range ~n a b generates a uniform sampling of n points between a and b (with the bounds a and b included in the list of points) together with colors (based on hue at the moment).

parameter grad

generate colors using the given gradient. Default: use the hue.

val with_colors : ?⁠grad:Gradient.t -> 'a list -> ('a * rgba) list

with_colors l add a color range to the list l.

parameter grad

generate colors using the given gradient. Default: use the hue.

Color palettes (aka colormaps)

module Palette : sig ... end

Colormaps with certain characteristics.