package stk

  1. Overview
  2. Docs
SDL-based GUI toolkit

Install

Dune Dependency

Authors

Maintainers

Sources

ocaml-stk-0.2.0.tar.bz2
md5=84927cce2b859a484df176163a68a21c
sha512=7d79d0b18c1550d59932ec27e5162f5ec5cfeb6560de32224cc7915f392e11d2c2fd94c44128b4b828b6ed700c2f079d120b2423874d71544e71bbab9253e870

doc/stk/Stk/Color/index.html

Module Stk.ColorSource

Colors.

Sourcetype t = int32

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

Sourcemodule Map : Map.S with type key = t
Sourceval compare : t -> t -> int
Sourceval pp : Format.formatter -> t -> unit
Sourceval to_int8s : t -> int * int * int * int

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

Sourceval of_rgba : int -> int -> int -> int -> t

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

Sourceval of_rgba_0_1 : float -> float -> float -> float -> t

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.

Sourceval to_sdl_color : t -> Tsdl.Sdl.color

to_sdl_color n creates a Tsdl.Sdl.color from a color.

Sourceval of_hexa : string -> t

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.

Sourceval transparent : t

The transparent color.

Sourceval transparent_int8s : int * int * int * int

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

Sourceval transparent_sdl : Tsdl.Sdl.color

Transparent SDL color.

Sourceval to_string : ?as_name:bool -> t -> string

to_string c returns a string representation of color c in the form 0xhhhhhhhh (classical hexadecimal values for components red, green, blue and alpha). Optional parameter as_name (default:true) indicates if the name of the color must be returned rather than its hexadecimal representation, when a name is registered for this color (see register_color).

Sourceval of_string : string -> t

of_string s returns the color associated to the given string (case-sensitive) in the registered colors. If no color with this name is found, then 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.

Registered colors

Sourceval register : string -> t -> unit

register_color name c registers color c with name so that it can be parsed (see of_string) and printed (see to_string using this name. If a color with the same name was already registered, a warning is issued and the new binding replaces the previous one. Same if another name was already associated to c.

Sourceval registered : unit -> (string * t) list

registered () return the list of registered colors in the form (name, color).

Sourceval random : unit -> t

random () returns a random color among the registered colors.

Sourceval ocf_wrapper : t Ocf.wrapper

Ocf.wrapper wrapper for a color.

Predefined colors

The following colors are already registered. These named colors corresponds to the SVG color specification.

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

Innovation. Community. Security.