# Module `gears.color`

### Info:

- Copyright: 2010 Uli Schlachter
- Release: v3.5.4
- Author: Uli Schlachter

## Functions

parse_color (col) | Parse a HTML-color.
create_solid_pattern (col) | Create a solid pattern
create_png_pattern (file) | Create an image pattern from a png file
create_linear_pattern (arg) | Create a linear pattern object.
create_radial_pattern (arg) | Create a radial pattern object.
create_pattern (col) | Create a pattern from a given string.
create_opaque_pattern (col) | Check if a pattern is opaque.

## Tables

types | Mapping of all supported color types.

## Functions

parse_color (col)
  Parse a HTML-color. This function can parse colors like #rrggbb and #rrggbbaa. For example, parse_color("#00ff00ff") would return 0, 1, 0, 1. Thanks to #lua for this. :)

  ### Parameters:

  - col The color to parse

  ### Returns:

  4 values which each are in the range [0, 1].
create_solid_pattern (col)
  Create a solid pattern

  ### Parameters:

  - col The color for the pattern

  ### Returns:

  A cairo pattern object
create_png_pattern (file)
  Create an image pattern from a png file

  ### Parameters:

  - file The filename of the file

  ### Returns:

  a cairo pattern object
create_linear_pattern (arg)
  Create a linear pattern object. The pattern is created from a string. This string should have the following form: "x0,y0:x1,y1:<stops>" Alternatively, the pattern can be specified as a table: { type = "linear", from = { x0, y0 }, to = { x1, y1 }, stops = { <stops> } } x0,y0 and x1,y1 are the start and stop point of the pattern. For the explanation of "<stops>", see create_pattern().

  ### Parameters:

  - arg The argument describing the pattern

  ### Returns:

  a cairo pattern object
create_radial_pattern (arg)
  Create a radial pattern object. The pattern is created from a string. This string should have the following form: "x0,y0,r0:x1,y1,r1:<stops>" Alternatively, the pattern can be specified as a table: { type = "radial", from = { x0, y0, r0 }, to = { x1, y1, r1 }, stops = { <stops> } } x0,y0 and x1,y1 are the start and stop point of the pattern. r0 and r1 are the radii of the start / stop circle. For the explanation of "<stops>", see create_pattern().

  ### Parameters:

  - arg The argument describing the pattern

  ### Returns:

  a cairo pattern object
create_pattern (col)
  Create a pattern from a given string. This function can create solid, linear, radial and png patterns. In general, patterns are specified as strings formatted as"type:arguments". "arguments" is specific to the pattern used. For example, one can use "radial:50,50,10:55,55,30:0,#ff0000:0.5,#00ff00:1,#0000ff" Alternatively, patterns can be specified via tables. In this case, the table's 'type' member specifies the type. For example: { type = "radial", from = { 50, 50, 10 }, to = { 55, 55, 30 }, stops = { { 0, "#ff0000" }, { 0.5, "#00ff00" }, { 1, "#0000ff" } } } Any argument that cannot be understood is passed to create_solid_pattern().

  ### Parameters:

  - col The string describing the pattern.

  ### Returns:

  a cairo pattern object

  ### See also:

  - create_solid_pattern
  - create_png_pattern
  - create_linear_pattern
  - create_radial_pattern
create_opaque_pattern (col)
  Check if a pattern is opaque. A pattern is transparent if the background on which it gets drawn (with operator OVER) doesn't influence the visual result.

  ### Parameters:

  - col An argument that create_pattern() accepts

  ### Returns:

  The pattern if it is surely opaque, else nil

## Tables

types
  Mapping of all supported color types. New entries can be added.

  ### Fields:

  - solid
  - png
  - linear
  - radial

generated by LDoc 1.4.2