package ocaml-canvas

  1. Overview
  2. Docs

Color description and manipulation functions

type t

Abstract type for colors

val 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.

val to_rgb : t -> int * int * int

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

val 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.

val to_argb : t -> int * int * int * int

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

val 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.

val 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

val of_int32 : Int32.t -> t

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

val to_int32 : t -> Int32.t

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

val transpBlack : t

Predefined transparent black color

val transpWhite : t

Predefined transparent white color

val black : t

Predefined black color

val white : t

Predefined white color

val blue : t

Predefined blue color

val cyan : t

Predefined cyan color

val green : t

Predefined green color

val lime : t

Predefined lime color

val orange : t

Predefined orange color

val pink : t

Predefined pink color

val red : t

Predefined red color

val 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.

val define_color : string -> t -> t

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

OCaml

Innovation. Community. Security.