starling-framework
Version:
A fast, productive library for 2D cross-platform development.
117 lines • 4.27 kB
TypeScript
import Vector from "openfl/Vector";
declare namespace starling.utils {
/**
* A utility class containing predefined colors and methods converting between different
* * color representations.
* *
* * <p>The HSL and HSV calculations conform to theory and implementation found on
* * <a href="https://en.wikipedia.org/wiki/HSL_and_HSV">Wikipedia</a> and
* * <a href="https://www.rapidtables.com/convert/color/">rapidtables.com</a>.</p>
*
*/
export class Color {
static readonly WHITE = 16777215;
static readonly SILVER = 12632256;
static readonly GRAY = 8421504;
static readonly BLACK = 0;
static readonly RED = 16711680;
static readonly MAROON = 8388608;
static readonly YELLOW = 16776960;
static readonly OLIVE = 8421376;
static readonly LIME = 65280;
static readonly GREEN = 32768;
static readonly AQUA = 65535;
static readonly TEAL = 32896;
static readonly BLUE = 255;
static readonly NAVY = 128;
static readonly FUCHSIA = 16711935;
static readonly PURPLE = 8388736;
/**
* Returns the alpha part of an ARGB color (0 - 255).
*/
static getAlpha(color: number): number;
/**
* Returns the red part of an (A)RGB color (0 - 255).
*/
static getRed(color: number): number;
/**
* Returns the green part of an (A)RGB color (0 - 255).
*/
static getGreen(color: number): number;
/**
* Returns the blue part of an (A)RGB color (0 - 255).
*/
static getBlue(color: number): number;
/**
* Sets the alpha part of an ARGB color (0 - 255).
*/
static setAlpha(color: number, alpha: number): number;
/**
* Sets the red part of an (A)RGB color (0 - 255).
*/
static setRed(color: number, red: number): number;
/**
* Sets the green part of an (A)RGB color (0 - 255).
*/
static setGreen(color: number, green: number): number;
/**
* Sets the blue part of an (A)RGB color (0 - 255).
*/
static setBlue(color: number, blue: number): number;
/**
* Creates an RGB color, stored in an unsigned integer. Channels are expected
* * in the range 0 - 255.
*/
static rgb(red: number, green: number, blue: number): number;
/**
* Creates an ARGB color, stored in an unsigned integer. Channels are expected
* * in the range 0 - 255.
*/
static argb(alpha: number, red: number, green: number, blue: number): number;
/**
* Creates an RGB color from hue, saturation and value (brightness).
* * Assumes hue, saturation, and value are contained in the range [0, 1].
*
*/
static hsv(hue: number, saturation: number, value: number): number;
/**
* Creates an RGB color from hue, saturation and lightness.
* * Assumes hue, saturation, and lightness are contained in the range [0, 1].
*
*/
static hsl(hue: number, saturation: number, lightness: number): number;
/**
* Converts an RGB color into a vector with HSV components.
* *
* * @param rgb the standard RGB color
* * @param hsv a vector to be used for the result; passing null will create a new one.
* * @return a vector containing hue, saturation, and value, in this order. Range: [0..1]
*
*/
static rgbToHsv(rgb: number, hsv?: Vector<number>): Vector<number>;
/**
* Converts an RGB color into a vector with HSV components.
* *
* * @param rgb the standard RGB color
* * @param hsl a vector to be used for the result; passing null will create a new one.
* * @return a vector containing hue, saturation, and lightness, in this order. Range: [0..1]
*
*/
static rgbToHsl(rgb: number, hsl?: Vector<number>): Vector<number>;
/**
* Converts a color to a vector containing the RGBA components (in this order) scaled
* * between 0 and 1.
*/
static toVector(color: number, out?: Vector<number>): Vector<number>;
/**
* Multiplies all channels of an (A)RGB color with a certain factor.
*/
static multiply(color: number, factor: number): number;
/**
* Calculates a smooth transition between one color to the next.
* * <code>ratio</code> is expected between 0 and 1.
*/
static interpolate(startColor: number, endColor: number, ratio: number): number;
}
}
export default starling.utils.Color;