package ocaml-canvas

  1. Overview
  2. Docs

Module V1.ColorSource

Color description and manipulation functions

Sourcetype t

Abstract type for colors

Sourceval of_rgb : int -> int -> int -> t

of_rgb r g b creates a color from its r, g and b components. Those components are automatically clipped to the 0-255 range.

Sourceval to_rgb : t -> int * int * int

to_rgb c converts a color to its r, g and b components, ignoring the alpha component

Sourceval of_argb : int -> int -> int -> int -> t

of_argb a r g b creates a color from it a, r, g and b components. Those components are automatically clipped to the 0-255 range.

Sourceval to_argb : t -> int * int * int * int

to_argb c converts a color to its a, r, g and b components

Sourceval of_int : int -> t

of_int i creates a color from its 24-bit integer representation i ; this representation does not include the alpha component. This integer is clipped to 24-bit beforehand.

Sourceval to_int : t -> int

to_int c converts a color c to its 24-bit integer representation ; this representation does not include the alpha component

Sourceval of_int32 : Int32.t -> t

of_int i creates a color from its 32-bit integer representation i

Sourceval to_int32 : t -> Int32.t

to_int c converts a color c to its 32-bit integer representation

Sourceval transpBlack : t

Predefined transparent black color

Sourceval transpWhite : t

Predefined transparent white color

Sourceval black : t

Predefined black color

Sourceval white : t

Predefined white color

Sourceval blue : t

Predefined blue color

Sourceval cyan : t

Predefined cyan color

Sourceval green : t

Predefined green color

Sourceval lime : t

Predefined lime color

Sourceval orange : t

Predefined orange color

Sourceval pink : t

Predefined pink color

Sourceval red : t

Predefined red color

Sourceval of_string : string -> t

of_string s returns the color associated with string s. s can be either a color name (as defined by define_color), or an hexadecimal representation of the form #AARRGGBB. If the color is unknown or unparsable, this returns transparent_black.

Sourceval define_color : string -> t -> t

define_color s c add a color c named n to the internal color map