node-libpng
Version:
Unofficial bindings for node to libpng.
44 lines (43 loc) • 1.53 kB
TypeScript
import { ColorGrayScaleAlpha } from "./gray-scale-alpha";
import { ColorGrayScale } from "./gray-scale";
import { ColorRGB } from "./rgb";
import { ColorPalette, Palette } from "./palette";
/**
* Represents a color of color type `ColorType.RGBA`.
*
* @see ColorType
*/
export declare type ColorRGBA = [number, number, number, number] & {
r: number;
g: number;
b: number;
a: number;
};
/**
* Create a new color of type `number`.
*
* @param r The value for the `red` part of the color.
* @param g The value for the `green` part of the color.
* @param b The value for the `blue` part of the color.
* @param a The value for the alpha channel part of the color.
*
* @return The color in rgba representation.
*/
export declare function colorRGBA(r: number, g: number, b: number, a: number): ColorRGBA;
/**
* Checks if the given parameter is a color of type `ColorRGBA`.
*
* @param color The input to check.
*
* @return `true` if `color` was of type `ColorRGBA` and `false` otherwise.
*/
export declare function isColorRGBA(color: any): color is ColorRGBA;
/**
* Convert a color in any format to rgba format.
*
* @param color The color to convert.
* @param palette The palette to use if the color is in palette format. Will be ignored otherwise.
*
* @return The color converted to rgba format or `undefined` if the color couldn't be converted.
*/
export declare function convertToRGBA(color: ColorGrayScaleAlpha | ColorGrayScale | ColorRGB | ColorPalette | ColorRGBA, palette?: Palette): ColorRGBA;