PageRenderTime 82ms CodeModel.GetById 32ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): GPL-2.0
  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
 21(**This module contains a few types and values to ease the use of CSS properties
 22   and such. If you think a feature is missing, consider sending a patch or an
 23   RFE to the mailing list.
 24
 25   This module contain submodules each with a signature similar to:
 26     type t            (*type the module is focused on*)
 27     type js_t         (*valid js representation of values of type t*)
 28     val js: t -> js_t (*conversion*)
 29     val ml: js_t -> t (*conversion*)
 30
 31    Additional functions (string conversion, standard operation, etc.) are
 32    sometime available. Some module have several different types instead of just
 33    one.
 34
 35*)
 36
 37module Color : sig
 38
 39(**All about CSS colors. MDC documentation here:
 40  https://developer.mozilla.org/en/CSS/color_value . Specifications here:
 41  http://www.w3.org/TR/css3-color/#svg-color .*)
 42
 43(**The colors by name.*)
 44type name =
 45  | Aliceblue | Antiquewhite | Aqua | Aquamarine | Azure
 46  | Beige | Bisque | Black | Blanchedalmond | Blue | Blueviolet | Brown
 47  | Burlywood
 48  | Cadetblue | Chartreuse | Chocolate | Coral | Cornflowerblue | Cornsilk
 49  | Crimson | Cyan
 50  | Darkblue | Darkcyan | Darkgoldenrod | Darkgray | Darkgreen | Darkgrey
 51  | Darkkhaki | Darkmagenta | Darkolivegreen | Darkorange | Darkorchid | Darkred
 52  | Darksalmon | Darkseagreen | Darkslateblue | Darkslategray | Darkslategrey
 53  | Darkturquoise | Darkviolet | Deeppink | Deepskyblue | Dimgray | Dimgrey
 54  | Dodgerblue
 55  | Firebrick | Floralwhite | Forestgreen | Fuchsia
 56  | Gainsboro | Ghostwhite | Gold | Goldenrod | Gray | Grey | Green
 57  | Greenyellow
 58  | Honeydew | Hotpink
 59  | Indianred | Indigo | Ivory
 60  | Khaki
 61  | Lavender | Lavenderblush | Lawngreen | Lemonchiffon | Lightblue | Lightcoral
 62  | Lightcyan | Lightgoldenrodyellow | Lightgray | Lightgreen | Lightgrey
 63  | Lightpink | Lightsalmon | Lightseagreen | Lightskyblue | Lightslategray
 64  | Lightslategrey | Lightsteelblue | Lightyellow | Lime | Limegreen | Linen
 65  | Magenta | Maroon | Mediumaquamarine | Mediumblue | Mediumorchid
 66  | Mediumpurple | Mediumseagreen | Mediumslateblue | Mediumspringgreen
 67  | Mediumturquoise | Mediumvioletred | Midnightblue | Mintcream | Mistyrose
 68  | Moccasin
 69  | Navajowhite | Navy
 70  | Oldlace | Olive | Olivedrab | Orange | Orangered | Orchid
 71  | Palegoldenrod | Palegreen | Paleturquoise | Palevioletred | Papayawhip
 72  | Peachpuff | Peru | Pink | Plum | Powderblue | Purple
 73  | Red | Rosybrown | Royalblue
 74  | Saddlebrown | Salmon | Sandybrown | Seagreen | Seashell | Sienna | Silver
 75  | Skyblue | Slateblue | Slategray | Slategrey | Snow | Springgreen | Steelblue
 76  | Tan | Teal | Thistle | Tomato | Turquoise
 77  | Violet
 78  | Wheat | White | Whitesmoke
 79  | Yellow | Yellowgreen
 80
 81(**Gives the string equivalent of the argument.*)
 82val string_of_name : name -> string
 83
 84(**Converts a color name into three integers representing the Red, Green and
 85  Blue channels. Channel values are in between [0] and [255].*)
 86val rgb_of_name : name -> (int * int * int)
 87
 88
 89(**The type of colors, either by name, by Red-Green-Blue constructor or by
 90   Hue-Saturation-Lightness constructors.*)
 91type t =
 92
 93  | Name of name
 94  (**A color by name*)
 95
 96  | RGB of (int * int * int)
 97  (**Red, Green and Blue values. Clipped to [0..255] by most (All?)
 98     browsers.*)
 99
100  | RGB_percent of (int * int * int)
101  (**RBG channels are specified as a percentage of their maximal value.*)
102
103  | RGBA of (int * int * int * float)
104  (**Same as RGB with additionnal transparency argument. Opacity should be
105    between [0.] (completely transparent) and [1.] (completely opaque).*)
106
107  | RGBA_percent of (int * int * int * float)
108  (**RGB channels specified as percentage of their maximal value. Alpha
109    channel (opacity) is still a [0.] to [1.] float.*)
110
111  | HSL of (int * int * int)
112  (**Hue, Saturation and Lightness values. Hue is an angle in degree (in
113     interval [0..360]). Saturation is a percentage ([0..100]) with [0]
114     being colorless. Lightness is also a percentage ([0..100]) with [0]
115     being black.*)
116
117  | HSLA of (int * int * int * float)
118  (**Same as HSL with an opacity argument between [0.] and [1.].*)
119
120
121(**build a color from the values of red, green, and blue channels. optional [a]
122   argument can be used to specify alpha channel (aka opacity).*)
123val rgb : ?a:float -> int -> int -> int -> t
124
125(**build a color from the values of hue, saturation, and lightness channels.
126   optional [a] argument can be used to specify alpha channel (aka opacity).*)
127val hsl : ?a:float -> int -> int -> int -> t
128
129(**A [js_t] is a valid string representation of a CSS color*)
130type js_t = private Js.js_string Js.t
131
132(**A few conversion functions*)
133
134(**Convert to a string representation (for debugging purpose mainly).*)
135val string_of_t: t -> string
136
137(**Projection from OCaml to Js. [js c] is equivalent
138to [Js.string (string_of_t c)] but with a [js_t] return type.*)
139val js : t -> js_t
140
141(**Projection from Js to OCaml. The function is the dual of [js].*)
142val ml: js_t -> t
143
144(**Checks the well-formedness of a string or fails with [Invalid_argument]*)
145val js_t_of_js_string : Js.js_string Js.t -> js_t
146
147end
148
149module Length : sig
150
151  (**The type of length attributes. Mdc documentation:
152    https://developer.mozilla.org/en/CSS/length and specification:
153    http://www.w3.org/TR/css3-values/#lengths
154    *)
155  type t =
156    | Zero (**For 0, unit is optional*)
157    | Em  of float (**Relative to the font size *)
158    | Ex  of float (**Relative to the x-height *)
159    | Px  of float (**Relative to the viewing device *)
160    | Gd  of float (**Relative to the grid *)
161    | Rem of float (**Relative to the font size of the root *)
162    | Vw  of float (**Relative to the viewport's width *)
163    | Vh  of float (**Relative to the viewport's height *)
164    | Vm  of float (**Relative to the smallest of the viewport's width or height *)
165    | Ch  of float (**Relative to the width of a char '0' *)
166    | Mm of float (** in Milimeter *)
167    | Cm of float (** in Centimeter *)
168    | In of float (** in Inch *)
169    | Pt of float (** in Points (72pt = 1in)*)
170    | Pc of float (** in Picas (1pc = 12pt)*)
171
172  (** Js representation of lengths. *)
173  type js_t = private Js.js_string Js.t
174
175  (**Conversion functions*)
176
177  val string_of_t: t -> string
178  val js: t -> js_t
179  val ml: js_t -> t
180
181end
182
183module Angle : sig
184
185  type t =
186    | Deg   of float
187    | Grad  of float
188    | Rad   of float
189    | Turns of float
190
191  type js_t = private Js.js_string Js.t
192
193  val string_of_t: t -> string
194  val js: t -> js_t
195  val ml: js_t -> t
196
197end