color - ICE 0.1 API documentation

ICE 0.1 API documentation

# color

RGBA Color struct and utility functions.

enum ColorFormat;

  Represents color formats used by images and screen.

  RGB_565

    16-bit RGB without alpha.

  RGB_8

    24-bit RGB.

  RGBA_8

    32-bit RGBA.

  GRAY_8

    8-bit grayscale.

pure uint bytesPerPixel(const ColorFormat format);

  Return number of bytes specified color format uses per pixel.

  Parameters:

  ColorFormat format | Color format to check.

  Returns:
  Bytes per pixel needed by specified color format.
struct Color;

  32-bit RGBA8 color.

  ubyte r;

    Red channel.

  ubyte g;

    Green channel.

  ubyte b;

    Blue channel.

  ubyte a;

    Alpha channel.

  static immutable Color white;

    Common color constants, identical to HTML.

  pure this(const(ubyte) r, const(ubyte) g, const(ubyte) b, const(ubyte) a);

    Construct a color.

    Parameters:

    const(ubyte) r | Red channel value.
    const(ubyte) g | Green channel value.
    const(ubyte) b | Blue channel value.
    const(ubyte) a | Alpha channel value.

  const pure nothrow int opCmp(ref const Color c);

    Comparison for sorting.

  const @property ubyte average();

    Return the average RGB intensity of the color.

  const @property ubyte lightness();

    Return lightness of the color.

  const @property ubyte luminance();

    Return luminance of the color.

  const pure Color opBinary(string op)(const Color c);

    Add two colors (values are clamped to range 0 .. 255).

  const Color opBinary(string op)(const float m);

    Multiply a color by a float (values are clamped to range 0 .. 255).

  pure void opOpAssign(string op)(const Color c);

    Add a color to this color (values are clamped to range 0 .. 255).

  void opOpAssign(string op)(const float m);

    Multiply this color by a float (values are clamped to range 0 .. 255).

  const Color interpolated(const Color c, const float d);

    Interpolate this color to another color.

    Parameters:

    Color c | Color to interpolate with.
    float d | Interpolation ratio. 1 is this color, 0 other color, 0.5 half in between. Must be in 0.0 .. 1.0 range.

  pure @property void gray8(const ubyte gray);

    Set grayscale color.

  pure void gammaCorrect(const real factor);

    Gamma correct the color with specified factor.

  static Color randomRGB();

    Return a random color with full opacity.

  static pure ubyte gammaCorrect(const ubyte color, const real factor);

    Gamma correct a GRAY_8 color.

    Parameters:

    ubyte color | Color (grayscale) to gamma correct.
    real factor | Gamma correction factor.

    Returns:
    Gamma corrected color.
template rgb(string c) if (c.length == 6)

  RGB color from a hexadecimal string (CSS style), e.g. FFFFFF for white.

template rgba(string c) if (c.length == 8)

  RGBA color from a hexadecimal string (CSS style), e.g. FFFFFF80 for half-transparent white.

template rgb(string c) if (c.length == 3)

  RGB color from a short hexadecimal string (CSS style), e.g. FFF for white.

template rgba(string c) if (c.length == 4)

  RGBA color from a short hexadecimal string (CSS style), e.g. FFF8 for half-transparent white.

pure ubyte hexColor(string hex);

  Get value of a 2-character hexadecimal sequence corresponding to single color channel.

Copyright © Ferdinand Majerech 2011. | Page generated by AutoDDoc and Ddoc.