Navigation
Synopsis The model used for defining colors.
Types alias Color = int;
Description A color is expressed in the RGB color space and consists of a red, green and blue ingredient; each can have a value in the range [0-255]. In addition, colors can have a transparency, expressed as a percentage between 0.0 (completely opaque) and 1.0 (completely transparent). One can also refer to colors by name. The full range of X11 (HTML) Colors is supported.

A color can be constructed using:
  • the integer value of the color (RGBA, 8 bits per color)
  • the rgb function that combines the red, green and blue ingredient into an integer representation of the color.
  • the color function that maps color names to color values.
  • the gray function that creates gray scale values.
  • the arbColor function that creates an arbitrary color.
The following properties use colors:
  • lineColor: sets the color of lines and borders.
  • fillColor: sets the color for filling the inside of a figure.
  • fontColor: sets the color for text.
all these properties accept a Color value or, for convenience, also a color name.
Examples
b1 = box([size(50), fillColor("MidNightBlue")]);
render(b1);
displays: b1

We can also use the RGB value of MidNightBlue directly
b2 = box([size(50), fillColor(rgb(25,25,112))]);
render(b2);
and obtain (unsurprisingly) the same result: b2
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.