package js_of_ocaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

All about CSS colors. MDC documentation here: https://developer.mozilla.org/en/CSS/color_value . Specifications here: http://www.w3.org/TR/css3-color/#svg-color .

type name =
  1. | Aliceblue
  2. | Antiquewhite
  3. | Aqua
  4. | Aquamarine
  5. | Azure
  6. | Beige
  7. | Bisque
  8. | Black
  9. | Blanchedalmond
  10. | Blue
  11. | Blueviolet
  12. | Brown
  13. | Burlywood
  14. | Cadetblue
  15. | Chartreuse
  16. | Chocolate
  17. | Coral
  18. | Cornflowerblue
  19. | Cornsilk
  20. | Crimson
  21. | Cyan
  22. | Darkblue
  23. | Darkcyan
  24. | Darkgoldenrod
  25. | Darkgray
  26. | Darkgreen
  27. | Darkgrey
  28. | Darkkhaki
  29. | Darkmagenta
  30. | Darkolivegreen
  31. | Darkorange
  32. | Darkorchid
  33. | Darkred
  34. | Darksalmon
  35. | Darkseagreen
  36. | Darkslateblue
  37. | Darkslategray
  38. | Darkslategrey
  39. | Darkturquoise
  40. | Darkviolet
  41. | Deeppink
  42. | Deepskyblue
  43. | Dimgray
  44. | Dimgrey
  45. | Dodgerblue
  46. | Firebrick
  47. | Floralwhite
  48. | Forestgreen
  49. | Fuchsia
  50. | Gainsboro
  51. | Ghostwhite
  52. | Gold
  53. | Goldenrod
  54. | Gray
  55. | Grey
  56. | Green
  57. | Greenyellow
  58. | Honeydew
  59. | Hotpink
  60. | Indianred
  61. | Indigo
  62. | Ivory
  63. | Khaki
  64. | Lavender
  65. | Lavenderblush
  66. | Lawngreen
  67. | Lemonchiffon
  68. | Lightblue
  69. | Lightcoral
  70. | Lightcyan
  71. | Lightgoldenrodyellow
  72. | Lightgray
  73. | Lightgreen
  74. | Lightgrey
  75. | Lightpink
  76. | Lightsalmon
  77. | Lightseagreen
  78. | Lightskyblue
  79. | Lightslategray
  80. | Lightslategrey
  81. | Lightsteelblue
  82. | Lightyellow
  83. | Lime
  84. | Limegreen
  85. | Linen
  86. | Magenta
  87. | Maroon
  88. | Mediumaquamarine
  89. | Mediumblue
  90. | Mediumorchid
  91. | Mediumpurple
  92. | Mediumseagreen
  93. | Mediumslateblue
  94. | Mediumspringgreen
  95. | Mediumturquoise
  96. | Mediumvioletred
  97. | Midnightblue
  98. | Mintcream
  99. | Mistyrose
  100. | Moccasin
  101. | Navajowhite
  102. | Navy
  103. | Oldlace
  104. | Olive
  105. | Olivedrab
  106. | Orange
  107. | Orangered
  108. | Orchid
  109. | Palegoldenrod
  110. | Palegreen
  111. | Paleturquoise
  112. | Palevioletred
  113. | Papayawhip
  114. | Peachpuff
  115. | Peru
  116. | Pink
  117. | Plum
  118. | Powderblue
  119. | Purple
  120. | Red
  121. | Rosybrown
  122. | Royalblue
  123. | Saddlebrown
  124. | Salmon
  125. | Sandybrown
  126. | Seagreen
  127. | Seashell
  128. | Sienna
  129. | Silver
  130. | Skyblue
  131. | Slateblue
  132. | Slategray
  133. | Slategrey
  134. | Snow
  135. | Springgreen
  136. | Steelblue
  137. | Tan
  138. | Teal
  139. | Thistle
  140. | Tomato
  141. | Turquoise
  142. | Violet
  143. | Wheat
  144. | White
  145. | Whitesmoke
  146. | Yellow
  147. | Yellowgreen

The colors by name.

val string_of_name : name -> string

Gives the string equivalent of the argument.

val rgb_of_name : name -> int * int * int

Converts a color name into three integers representing the Red, Green and Blue channels. Channel values are in between 0 and 255.

val hex_of_rgb : (int * int * int) -> string

Convert a tuple of three integers between 0 and 255 into a hex string

type t =
  1. | Name of name
    (*

    A color by name

    *)
  2. | RGB of int * int * int
    (*

    Red, Green and Blue values. Clipped to 0..255 by most (All?) browsers.

    *)
  3. | RGB_percent of int * int * int
    (*

    RBG channels are specified as a percentage of their maximal value.

    *)
  4. | RGBA of int * int * int * float
    (*

    Same as RGB with additionnal transparency argument. Opacity should be between 0. (completely transparent) and 1. (completely opaque).

    *)
  5. | RGBA_percent of int * int * int * float
    (*

    RGB channels specified as percentage of their maximal value. Alpha channel (opacity) is still a 0. to 1. float.

    *)
  6. | HSL of int * int * int
    (*

    Hue, Saturation and Lightness values. Hue is an angle in degree (in interval 0..360). Saturation is a percentage (0..100) with 0 being colorless. Lightness is also a percentage (0..100) with 0 being black.

    *)
  7. | HSLA of int * int * int * float
    (*

    Same as HSL with an opacity argument between 0. and 1..

    *)

The type of colors, either by name, by Red-Green-Blue constructor or by Hue-Saturation-Lightness constructors.

val rgb : ?a:float -> int -> int -> int -> t

build a color from the values of red, green, and blue channels. optional a argument can be used to specify alpha channel (aka opacity).

val hsl : ?a:float -> int -> int -> int -> t

build a color from the values of hue, saturation, and lightness channels. optional a argument can be used to specify alpha channel (aka opacity).

A js_t is a valid string representation of a CSS color

A few conversion functions

val string_of_t : t -> string

Convert to a string representation (for debugging purpose mainly).

val js : t -> js_t

Projection from OCaml to Js. js c is equivalent to Js.string (string_of_t c) but with a js_t return type.

val ml : js_t -> t

Projection from Js to OCaml. The function is the dual of js.

Checks the well-formedness of a string or fails with Invalid_argument

OCaml

Innovation. Community. Security.