package stk

  1. Overview
  2. Docs

Colors.

type t = int32

A color is a int32, with bytes representing red, green, blue and alpha (opacity).

val compare : Int32.t -> Int32.t -> int
val pp : Format.formatter -> int32 -> unit
val to_int8s : int32 -> int * int * int * int

to_int8s color returns (red, green, blue, alpha) components of color.

val of_rgba : int -> int -> int -> int -> int32

of_rgba r g b a returns a color from the given components.

val of_rgba_0_1 : float -> float -> float -> float -> int32

of_rgba_0_1 r g b a returns a color from the given components as floats. Each component must be between 0. and 1. and is multiplicated by 255 to get the value on one byte for this component. Out of bounds values are corrected to be at least 0 and at most 255.

val sdl_color_of_int32 : int32 -> Tsdl.Sdl.color

sdl_color_of_int32 n creates a Tsdl.Sdl.color.

val of_hexa : string -> int32

Returns a color from a hexadecimal string representation. With each character being 0..9 or a|A..f|F, accepted forms are:

  • "rgb", mapped to (rr,gg,bb,FF),
  • "rgba", mapped to (rr,gg,bb,aa),
  • "rrggbb", mapped to (rr,gg,bb,FF),
  • any other string s which can be parsed by Int32.of_string ("0x"^s).

Raises Failure if the representation is invalid.

val transparent : int32

The transparent color.

val transparent_int8s : int * int * int * int

Transparent color as (r,g,b,a) bytes.

val transparent_color : Tsdl.Sdl.color

Transparent SDL color.

Named colors

Thes named colors corresponds to the SVG color specification.

val aliceblue : t
val antiquewhite : t
val aqua : t
val aquamarine : t
val azure : t
val beige : t
val bisque : t
val black : t
val blanchedalmond : t
val blue : t
val blueviolet : t
val brown : t
val burlywood : t
val cadetblue : t
val chartreuse : t
val chocolate : t
val coral : t
val cornflowerblue : t
val cornsilk : t
val crimson : t
val cyan : t
val darkblue : t
val darkcyan : t
val darkgoldenrod : t
val darkgray : t
val darkgreen : t
val darkgrey : t
val darkkhaki : t
val darkmagenta : t
val darkolivegreen : t
val darkorange : t
val darkorchid : t
val darkred : t
val darksalmon : t
val darkseagreen : t
val darkslateblue : t
val darkslategray : t
val darkslategrey : t
val darkturquoise : t
val darkviolet : t
val deeppink : t
val deepskyblue : t
val dimgray : t
val dimgrey : t
val dodgerblue : t
val firebrick : t
val floralwhite : t
val forestgreen : t
val fuchsia : t
val gainsboro : t
val ghostwhite : t
val gold : t
val goldenrod : t
val gray : t
val green : t
val greenyellow : t
val grey : t
val honeydew : t
val hotpink : t
val indianred : t
val indigo : t
val ivory : t
val khaki : t
val lavender : t
val lavenderblush : t
val lawngreen : t
val lemonchiffon : t
val lightblue : t
val lightcoral : t
val lightcyan : t
val lightgoldenrodyellow : t
val lightgray : t
val lightgreen : t
val lightgrey : t
val lightpink : t
val lightsalmon : t
val lightseagreen : t
val lightskyblue : t
val lightslategray : t
val lightslategrey : t
val lightsteelblue : t
val lightyellow : t
val lime : t
val limegreen : t
val linen : t
val magenta : t
val maroon : t
val mediumaquamarine : t
val mediumblue : t
val mediumorchid : t
val mediumpurple : t
val mediumseagreen : t
val mediumslateblue : t
val mediumspringgreen : t
val mediumturquoise : t
val mediumvioletred : t
val midnightblue : t
val mintcream : t
val mistyrose : t
val moccasin : t
val navajowhite : t
val navy : t
val oldlace : t
val olive : t
val olivedrab : t
val orange : t
val orangered : t
val orchid : t
val palegoldenrod : t
val palegreen : t
val paleturquoise : t
val palevioletred : t
val papayawhip : t
val peachpuff : t
val peru : t
val pink : t
val plum : t
val powderblue : t
val purple : t
val red : t
val rosybrown : t
val royalblue : t
val saddlebrown : t
val salmon : t
val sandybrown : t
val seagreen : t
val seashell : t
val sienna : t
val silver : t
val skyblue : t
val slateblue : t
val slategray : t
val slategrey : t
val snow : t
val springgreen : t
val steelblue : t
val tan : t
val teal : t
val thistle : t
val tomato : t
val turquoise : t
val violet : t
val wheat : t
val white : t
val whitesmoke : t
val yellow : t
val yellowgreen : t
val of_name : string -> t

of_name s returns the color associated to the given string (case-sensitive). Else, if s begin with '#', the rest of the string is parsed with of_hexa. If it fails or if the string does not start with '#', the black color is returned.

val named_colors : t list

The list of named colors.

val random : unit -> t

random () returns a random color from the list of named colors.

val ocf_wrapper : t Ocf.wrapper

Ocf.wrapper for a color.

OCaml

Innovation. Community. Security.