Unit CastleColors

Classes, Interfaces, Objects and Records
Variables

Description

Color utilities, including HSV <-> RGB conversion.

Uses

Overview

Functions and Procedures

function GrayscaleValue(const v: TCastleColorRGB): Single; inline; overload;
function GrayscaleValue(const v: TCastleColor): Single; inline; overload;
function GrayscaleValue(const v: TVector3Byte): Byte; inline; overload;
function GrayscaleValue(const v: TVector4Byte): Byte; inline; overload;
function Grayscale(const v: TCastleColorRGB): TCastleColorRGB; inline; overload;
function Grayscale(const v: TVector3Byte): TVector3Byte; inline; overload;
function Grayscale(const v: TCastleColor): TCastleColor; inline; overload;
function ColorGrayscaleByte(const Color: TVector3Byte): TVector3Byte;
function ColorRedConvertByte(const Color: TVector3Byte): TVector3Byte;
function ColorGreenConvertByte(const Color: TVector3Byte): TVector3Byte;
function ColorBlueConvertByte(const Color: TVector3Byte): TVector3Byte;
function ColorRedStripByte(const Color: TVector3Byte): TVector3Byte;
function ColorGreenStripByte(const Color: TVector3Byte): TVector3Byte;
function ColorBlueStripByte(const Color: TVector3Byte): TVector3Byte;
function HsvToRgb(const Value: TVector3): TVector3;
function RgbToHsv(const Value: TVector3): TVector3; overload;
function RgbToHsv(const Value: TVector3Byte): TVector3; overload;
function HsvToRgbByte(const Value: TVector3): TVector3Byte;
function LerpRgbInHsv(const A: Single; const V1, V2: TVector3): TVector3;
function ColorToHex(const V: TCastleColor): string;
function ColorRGBToHex(const V: TCastleColorRGB): string;
function HexToColor(const S: string): TCastleColor;
function HexToColorRGB(const S: string): TCastleColorRGB;
function ColorOpacity(const Color: TCastleColor; const Opacity: Single): TCastleColor;
function FadeDarkColor(const Color: TCastleColor; const FadeIntensity: Single): TCastleColor;
function FadeColor(const Color: TCastleColor; const FadeIntensity: Single): TCastleColor;

Types

TCastleColor = TVector4;
TCastleColorRGB = TVector3;
TColorModulatorByteFunc = function (const Color: TVector3Byte): TVector3Byte;

Constants

Maroon : TCastleColor = (Data: ( 0.5 , 0.0 , 0.0 , 1.0));
Red : TCastleColor = (Data: ( 1.0 , 0.0 , 0.0 , 1.0));
Orange : TCastleColor = (Data: ( 1.0 , 0.65, 0.0 , 1.0));
Yellow : TCastleColor = (Data: ( 1.0 , 1.0 , 0.0 , 1.0));
Olive : TCastleColor = (Data: ( 0.5 , 0.5 , 0.0 , 1.0));
Purple : TCastleColor = (Data: ( 0.5 , 0.0 , 0.5 , 1.0));
Fuchsia: TCastleColor = (Data: ( 1.0 , 0.0 , 1.0 , 1.0));
White : TCastleColor = (Data: ( 1.0 , 1.0 , 1.0 , 1.0));
Lime : TCastleColor = (Data: ( 0.0 , 1.0 , 0.0 , 1.0));
Green : TCastleColor = (Data: ( 0.0 , 0.5 , 0.0 , 1.0));
Navy : TCastleColor = (Data: ( 0.0 , 0.0 , 0.5 , 1.0));
Blue : TCastleColor = (Data: ( 0.0 , 0.0 , 1.0 , 1.0));
Aqua : TCastleColor = (Data: ( 0.0 , 1.0 , 1.0 , 1.0));
Teal : TCastleColor = (Data: ( 0.0 , 0.5 , 0.5 , 1.0));
Black : TCastleColor = (Data: ( 0.0 , 0.0 , 0.0 , 1.0));
Silver : TCastleColor = (Data: ( 0.75, 0.75, 0.75, 1.0));
Gray : TCastleColor = (Data: ( 0.5 , 0.5 , 0.5 , 1.0));
LightGreen: TCastleColor = (Data: ( 0.33, 1.0 , 0.33, 1.0));
LightBlue : TCastleColor = (Data: ( 0.33, 0.33, 1.0 , 1.0));
WhiteRGB : TCastleColorRGB = (Data: ( 1.0 , 1.0 , 1.0));
BlackRGB : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 0.0));
RedRGB : TCastleColorRGB = (Data: ( 1.0 , 0.0 , 0.0));
YellowRGB : TCastleColorRGB = (Data: ( 1.0 , 1.0 , 0.0));
GreenRGB : TCastleColorRGB = (Data: ( 0.0 , 0.5 , 0.0));
BlueRGB : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 1.0));
GrayRGB : TCastleColorRGB = (Data: ( 0.5 , 0.5 , 0.5));
White3Single : TCastleColorRGB = (Data: ( 1.0 , 1.0 , 1.0)) deprecated;
Black3Single : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 0.0)) deprecated;
Red3Single : TCastleColorRGB = (Data: ( 1.0 , 0.0 , 0.0)) deprecated;
Green3Single : TCastleColorRGB = (Data: ( 0.0 , 0.5 , 0.0)) deprecated;
Blue3Single : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 1.0)) deprecated;

Description

Functions and Procedures

function GrayscaleValue(const v: TCastleColorRGB): Single; inline; overload;

Calculate color intensity, for converting color to grayscale.

function GrayscaleValue(const v: TCastleColor): Single; inline; overload;
 
function GrayscaleValue(const v: TVector3Byte): Byte; inline; overload;
 
function GrayscaleValue(const v: TVector4Byte): Byte; inline; overload;
 
function Grayscale(const v: TCastleColorRGB): TCastleColorRGB; inline; overload;
 
function Grayscale(const v: TVector3Byte): TVector3Byte; inline; overload;
 
function Grayscale(const v: TCastleColor): TCastleColor; inline; overload;
 
function ColorGrayscaleByte(const Color: TVector3Byte): TVector3Byte;

Convert color to grayscale.

function ColorRedConvertByte(const Color: TVector3Byte): TVector3Byte;

Place color intensity (calculated like for grayscale) into the given color component. Set the other components zero.

function ColorGreenConvertByte(const Color: TVector3Byte): TVector3Byte;
 
function ColorBlueConvertByte(const Color: TVector3Byte): TVector3Byte;
 
function ColorRedStripByte(const Color: TVector3Byte): TVector3Byte;

Set color values for two other channels to 0. Note that it's something entirely different than ImageConvertToChannelVar: here we preserve original channel values, and remove values on two other channels.

function ColorGreenStripByte(const Color: TVector3Byte): TVector3Byte;
 
function ColorBlueStripByte(const Color: TVector3Byte): TVector3Byte;
 
function HsvToRgb(const Value: TVector3): TVector3;

Converting between RGB and HSV. For HSV, we keep components as floating-point values, with hue in 0..6 range, saturation and value in 0..1. For RGB, one version keeps components as bytes (0..255 range), and the other as floating-point values (0..1 range).

function RgbToHsv(const Value: TVector3): TVector3; overload;
 
function RgbToHsv(const Value: TVector3Byte): TVector3; overload;
 
function HsvToRgbByte(const Value: TVector3): TVector3Byte;
 
function LerpRgbInHsv(const A: Single; const V1, V2: TVector3): TVector3;

Given two colors in RGB, interpolate them in HSV space.

function ColorToHex(const V: TCastleColor): string;

Change color into a hexadecimal notation of it (like in HTML). This color includes an alpha channel (as 4th component), and so the output contains the alpha value at the end (so it's 8 hex digits), unless alpha is opaque in which case it's not written (and result is 6 hex digits).

function ColorRGBToHex(const V: TCastleColorRGB): string;

Change color into a hexadecimal notation of it (like in HTML). This color has no alpha channel, so it's always 6 hex digits.

function HexToColor(const S: string): TCastleColor;

Convert hexadecimal color notation (like in HTML) into an RGBA color. Handles 8 or 6 digit color (RGB or RGBA with 2 letters per component; for 6 digits, alpha is assumed to be 1.0 (opaque)).

Exceptions raised
EConvertError
In case of invalid color as string.
function HexToColorRGB(const S: string): TCastleColorRGB;

Convert hexadecimal color notation (like in HTML) into an RGB color. Handles 8 or 6 digit color (RGB or RGBA with 2 letters per component; for 8 digits, alpha is ignored).

Exceptions raised
EConvertError
In case of invalid color as string.
function ColorOpacity(const Color: TCastleColor; const Opacity: Single): TCastleColor;

Change color opacity (alpha).

function FadeDarkColor(const Color: TCastleColor; const FadeIntensity: Single): TCastleColor;
 
function FadeColor(const Color: TCastleColor; const FadeIntensity: Single): TCastleColor;
 

Types

TCastleColor = TVector4;
 
TCastleColorRGB = TVector3;
 
TColorModulatorByteFunc = function (const Color: TVector3Byte): TVector3Byte;

Function that processes RGB colors, used by TCastleImage.ModulateRGB.

Constants

Maroon : TCastleColor = (Data: ( 0.5 , 0.0 , 0.0 , 1.0));

Common color constants, for comfort. They follow the CSS colors constants [http://www.w3.org/TR/CSS21/syndata.html#color-units].

Red : TCastleColor = (Data: ( 1.0 , 0.0 , 0.0 , 1.0));
 
Orange : TCastleColor = (Data: ( 1.0 , 0.65, 0.0 , 1.0));
 
Yellow : TCastleColor = (Data: ( 1.0 , 1.0 , 0.0 , 1.0));
 
Olive : TCastleColor = (Data: ( 0.5 , 0.5 , 0.0 , 1.0));
 
Purple : TCastleColor = (Data: ( 0.5 , 0.0 , 0.5 , 1.0));
 
Fuchsia: TCastleColor = (Data: ( 1.0 , 0.0 , 1.0 , 1.0));
 
White : TCastleColor = (Data: ( 1.0 , 1.0 , 1.0 , 1.0));
 
Lime : TCastleColor = (Data: ( 0.0 , 1.0 , 0.0 , 1.0));
 
Green : TCastleColor = (Data: ( 0.0 , 0.5 , 0.0 , 1.0));
 
Navy : TCastleColor = (Data: ( 0.0 , 0.0 , 0.5 , 1.0));
 
Blue : TCastleColor = (Data: ( 0.0 , 0.0 , 1.0 , 1.0));
 
Aqua : TCastleColor = (Data: ( 0.0 , 1.0 , 1.0 , 1.0));
 
Teal : TCastleColor = (Data: ( 0.0 , 0.5 , 0.5 , 1.0));
 
Black : TCastleColor = (Data: ( 0.0 , 0.0 , 0.0 , 1.0));
 
Silver : TCastleColor = (Data: ( 0.75, 0.75, 0.75, 1.0));
 
Gray : TCastleColor = (Data: ( 0.5 , 0.5 , 0.5 , 1.0));
 
LightGreen: TCastleColor = (Data: ( 0.33, 1.0 , 0.33, 1.0));
 
LightBlue : TCastleColor = (Data: ( 0.33, 0.33, 1.0 , 1.0));
 
WhiteRGB : TCastleColorRGB = (Data: ( 1.0 , 1.0 , 1.0));
 
BlackRGB : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 0.0));
 
RedRGB : TCastleColorRGB = (Data: ( 1.0 , 0.0 , 0.0));
 
YellowRGB : TCastleColorRGB = (Data: ( 1.0 , 1.0 , 0.0));
 
GreenRGB : TCastleColorRGB = (Data: ( 0.0 , 0.5 , 0.0));
 
BlueRGB : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 1.0));
 
GrayRGB : TCastleColorRGB = (Data: ( 0.5 , 0.5 , 0.5));
 
White3Single : TCastleColorRGB = (Data: ( 1.0 , 1.0 , 1.0)) deprecated;

Warning: this symbol is deprecated.

Deprecated, use WhiteRGB.

Black3Single : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 0.0)) deprecated;

Warning: this symbol is deprecated.

Deprecated, use BlackRGB.

Red3Single : TCastleColorRGB = (Data: ( 1.0 , 0.0 , 0.0)) deprecated;

Warning: this symbol is deprecated.

Deprecated, use RedRGB.

Green3Single : TCastleColorRGB = (Data: ( 0.0 , 0.5 , 0.0)) deprecated;

Warning: this symbol is deprecated.

Deprecated, use GreenRGB.

Blue3Single : TCastleColorRGB = (Data: ( 0.0 , 0.0 , 1.0)) deprecated;

Warning: this symbol is deprecated.

Deprecated, use BlueRGB.


Generated by PasDoc 0.15.0.