/tryocaml/js_of_ocaml-patched/lib/CSS.mli

http://github.com/cago/tryocaml · OCaml · 197 lines · 95 code · 38 blank · 64 comment · 0 complexity · abd059b6b269d23e94a45381f5954afc MD5 · raw file

  1. (* Js_of_ocaml library
  2. * http://www.ocsigen.org/js_of_ocaml/
  3. * Copyright (C) 2010 Rapha??l Proust
  4. * Laboratoire PPS - CNRS Universit?Š Paris Diderot
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, with linking exception;
  9. * either version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *)
  20. (**This module contains a few types and values to ease the use of CSS properties
  21. and such. If you think a feature is missing, consider sending a patch or an
  22. RFE to the mailing list.
  23. This module contain submodules each with a signature similar to:
  24. type t (*type the module is focused on*)
  25. type js_t (*valid js representation of values of type t*)
  26. val js: t -> js_t (*conversion*)
  27. val ml: js_t -> t (*conversion*)
  28. Additional functions (string conversion, standard operation, etc.) are
  29. sometime available. Some module have several different types instead of just
  30. one.
  31. *)
  32. module Color : sig
  33. (**All about CSS colors. MDC documentation here:
  34. https://developer.mozilla.org/en/CSS/color_value . Specifications here:
  35. http://www.w3.org/TR/css3-color/#svg-color .*)
  36. (**The colors by name.*)
  37. type name =
  38. | Aliceblue | Antiquewhite | Aqua | Aquamarine | Azure
  39. | Beige | Bisque | Black | Blanchedalmond | Blue | Blueviolet | Brown
  40. | Burlywood
  41. | Cadetblue | Chartreuse | Chocolate | Coral | Cornflowerblue | Cornsilk
  42. | Crimson | Cyan
  43. | Darkblue | Darkcyan | Darkgoldenrod | Darkgray | Darkgreen | Darkgrey
  44. | Darkkhaki | Darkmagenta | Darkolivegreen | Darkorange | Darkorchid | Darkred
  45. | Darksalmon | Darkseagreen | Darkslateblue | Darkslategray | Darkslategrey
  46. | Darkturquoise | Darkviolet | Deeppink | Deepskyblue | Dimgray | Dimgrey
  47. | Dodgerblue
  48. | Firebrick | Floralwhite | Forestgreen | Fuchsia
  49. | Gainsboro | Ghostwhite | Gold | Goldenrod | Gray | Grey | Green
  50. | Greenyellow
  51. | Honeydew | Hotpink
  52. | Indianred | Indigo | Ivory
  53. | Khaki
  54. | Lavender | Lavenderblush | Lawngreen | Lemonchiffon | Lightblue | Lightcoral
  55. | Lightcyan | Lightgoldenrodyellow | Lightgray | Lightgreen | Lightgrey
  56. | Lightpink | Lightsalmon | Lightseagreen | Lightskyblue | Lightslategray
  57. | Lightslategrey | Lightsteelblue | Lightyellow | Lime | Limegreen | Linen
  58. | Magenta | Maroon | Mediumaquamarine | Mediumblue | Mediumorchid
  59. | Mediumpurple | Mediumseagreen | Mediumslateblue | Mediumspringgreen
  60. | Mediumturquoise | Mediumvioletred | Midnightblue | Mintcream | Mistyrose
  61. | Moccasin
  62. | Navajowhite | Navy
  63. | Oldlace | Olive | Olivedrab | Orange | Orangered | Orchid
  64. | Palegoldenrod | Palegreen | Paleturquoise | Palevioletred | Papayawhip
  65. | Peachpuff | Peru | Pink | Plum | Powderblue | Purple
  66. | Red | Rosybrown | Royalblue
  67. | Saddlebrown | Salmon | Sandybrown | Seagreen | Seashell | Sienna | Silver
  68. | Skyblue | Slateblue | Slategray | Slategrey | Snow | Springgreen | Steelblue
  69. | Tan | Teal | Thistle | Tomato | Turquoise
  70. | Violet
  71. | Wheat | White | Whitesmoke
  72. | Yellow | Yellowgreen
  73. (**Gives the string equivalent of the argument.*)
  74. val string_of_name : name -> string
  75. (**Converts a color name into three integers representing the Red, Green and
  76. Blue channels. Channel values are in between [0] and [255].*)
  77. val rgb_of_name : name -> (int * int * int)
  78. (**The type of colors, either by name, by Red-Green-Blue constructor or by
  79. Hue-Saturation-Lightness constructors.*)
  80. type t =
  81. | Name of name
  82. (**A color by name*)
  83. | RGB of (int * int * int)
  84. (**Red, Green and Blue values. Clipped to [0..255] by most (All?)
  85. browsers.*)
  86. | RGB_percent of (int * int * int)
  87. (**RBG channels are specified as a percentage of their maximal value.*)
  88. | RGBA of (int * int * int * float)
  89. (**Same as RGB with additionnal transparency argument. Opacity should be
  90. between [0.] (completely transparent) and [1.] (completely opaque).*)
  91. | RGBA_percent of (int * int * int * float)
  92. (**RGB channels specified as percentage of their maximal value. Alpha
  93. channel (opacity) is still a [0.] to [1.] float.*)
  94. | HSL of (int * int * int)
  95. (**Hue, Saturation and Lightness values. Hue is an angle in degree (in
  96. interval [0..360]). Saturation is a percentage ([0..100]) with [0]
  97. being colorless. Lightness is also a percentage ([0..100]) with [0]
  98. being black.*)
  99. | HSLA of (int * int * int * float)
  100. (**Same as HSL with an opacity argument between [0.] and [1.].*)
  101. (**build a color from the values of red, green, and blue channels. optional [a]
  102. argument can be used to specify alpha channel (aka opacity).*)
  103. val rgb : ?a:float -> int -> int -> int -> t
  104. (**build a color from the values of hue, saturation, and lightness channels.
  105. optional [a] argument can be used to specify alpha channel (aka opacity).*)
  106. val hsl : ?a:float -> int -> int -> int -> t
  107. (**A [js_t] is a valid string representation of a CSS color*)
  108. type js_t = private Js.js_string Js.t
  109. (**A few conversion functions*)
  110. (**Convert to a string representation (for debugging purpose mainly).*)
  111. val string_of_t: t -> string
  112. (**Projection from OCaml to Js. [js c] is equivalent
  113. to [Js.string (string_of_t c)] but with a [js_t] return type.*)
  114. val js : t -> js_t
  115. (**Projection from Js to OCaml. The function is the dual of [js].*)
  116. val ml: js_t -> t
  117. (**Checks the well-formedness of a string or fails with [Invalid_argument]*)
  118. val js_t_of_js_string : Js.js_string Js.t -> js_t
  119. end
  120. module Length : sig
  121. (**The type of length attributes. Mdc documentation:
  122. https://developer.mozilla.org/en/CSS/length and specification:
  123. http://www.w3.org/TR/css3-values/#lengths
  124. *)
  125. type t =
  126. | Zero (**For 0, unit is optional*)
  127. | Em of float (**Relative to the font size *)
  128. | Ex of float (**Relative to the x-height *)
  129. | Px of float (**Relative to the viewing device *)
  130. | Gd of float (**Relative to the grid *)
  131. | Rem of float (**Relative to the font size of the root *)
  132. | Vw of float (**Relative to the viewport's width *)
  133. | Vh of float (**Relative to the viewport's height *)
  134. | Vm of float (**Relative to the smallest of the viewport's width or height *)
  135. | Ch of float (**Relative to the width of a char '0' *)
  136. | Mm of float (** in Milimeter *)
  137. | Cm of float (** in Centimeter *)
  138. | In of float (** in Inch *)
  139. | Pt of float (** in Points (72pt = 1in)*)
  140. | Pc of float (** in Picas (1pc = 12pt)*)
  141. (** Js representation of lengths. *)
  142. type js_t = private Js.js_string Js.t
  143. (**Conversion functions*)
  144. val string_of_t: t -> string
  145. val js: t -> js_t
  146. val ml: js_t -> t
  147. end
  148. module Angle : sig
  149. type t =
  150. | Deg of float
  151. | Grad of float
  152. | Rad of float
  153. | Turns of float
  154. type js_t = private Js.js_string Js.t
  155. val string_of_t: t -> string
  156. val js: t -> js_t
  157. val ml: js_t -> t
  158. end