Castle Game Engine: CastleColors

# Unit CastleColors
Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables
## Description Color utilities, including HSV <-> RGB convertion. ## Uses Math CastleVectors ## Overview ### Functions and Procedures
`function GrayscaleValue(const v: TVector3Single): Single; overload;`
`function GrayscaleValue(const v: TVector3Double): Double; overload;`
`function GrayscaleValue(const v: TVector3Byte): Byte; overload;`
`function Grayscale(const v: TVector3Single): TVector3Single; overload;`
`function Grayscale(const v: TVector4Single): Tvector4Single; overload;`
`function Grayscale(const v: TVector3Byte): TVector3Byte; 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: TVector3Single): TVector3Single;`
`function RgbToHsv(const Value: TVector3Single): TVector3Single;`
`function RgbToHsv(const Value: TVector3Byte): TVector3Single;`
`function HsvToRgbByte(const Value: TVector3Single): TVector3Byte;`
`function LerpRgbInHsv(const A: Single; const V1, V2: TVector3Single): TVector3Single;`
`function ColorToHex(const V: TVector4Single): string;`
### Types
`TColorModulatorByteFunc = function (const Color: TVector3Byte): TVector3Byte;`
### Constants
`Black3Byte : TVector3Byte = ( 0, 0, 0);`
`Red3Byte : TVector3Byte = (255, 0, 0);`
`Green3Byte : TVector3Byte = ( 0, 255, 0);`
`Blue3Byte : TVector3Byte = ( 0, 0, 255);`
`White3Byte : TVector3Byte = (255, 255, 255);`
`Black4Byte : TVector4Byte = ( 0, 0, 0, 255);`
`Red4Byte : TVector4Byte = (255, 0, 0, 255);`
`Green4Byte : TVector4Byte = ( 0, 255, 0, 255);`
`Blue4Byte : TVector4Byte = ( 0, 0, 255, 255);`
`White4Byte : TVector4Byte = (255, 255, 255, 255);`
`Black3Single : TVector3Single = ( 0, 0, 0);`
`Blue3Single : TVector3Single = ( 0, 0, 0.6);`
`Green3Single : TVector3Single = ( 0, 0.6, 0);`
`Cyan3Single : TVector3Single = ( 0, 0.6, 0.6);`
`Red3Single : TVector3Single = ( 0.6, 0, 0);`
`Magenta3Single : TVector3Single = ( 0.6, 0, 0.6);`
`Brown3Single : TVector3Single = ( 0.6, 0.3, 0);`
`LightGray3Single : TVector3Single = ( 0.6, 0.6, 0.6);`
`DarkGray3Single : TVector3Single = ( 0.3, 0.3, 0.3);`
`LightBlue3Single : TVector3Single = ( 0.3, 0.3, 1);`
`LightGreen3Single : TVector3Single = ( 0.3, 1, 0.3);`
`LightCyan3Single : TVector3Single = ( 0.3, 1, 1);`
`LightRed3Single : TVector3Single = ( 1, 0.3, 0.3);`
`LightMagenta3Single : TVector3Single = ( 1, 0.3, 1);`
`Yellow3Single : TVector3Single = ( 1, 1, 0.3);`
`White3Single : TVector3Single = ( 1, 1, 1);`
`Gray3Single : TVector3Single = ( 0.5, 0.5, 0.5);`
`DarkGreen3Single : TVector3Single = ( 0, 0.3, 0);`
`DarkBrown3Single : TVector3Single = (0.63, 0.15, 0);`
`Orange3Single : TVector3Single = ( 1, 0.5, 0);`
`Black4Single : TVector4Single = ( 0, 0, 0, 1);`
`Blue4Single : TVector4Single = ( 0, 0, 0.6, 1);`
`Green4Single : TVector4Single = ( 0, 0.6, 0, 1);`
`Cyan4Single : TVector4Single = ( 0, 0.6, 0.6, 1);`
`Red4Single : TVector4Single = ( 0.6, 0, 0, 1);`
`Magenta4Single : TVector4Single = ( 0.6, 0, 0.6, 1);`
`Brown4Single : TVector4Single = ( 0.6, 0.3, 0, 1);`
`LightGray4Single : TVector4Single = ( 0.6, 0.6, 0.6, 1);`
`DarkGray4Single : TVector4Single = ( 0.3, 0.3, 0.3, 1);`
`LightBlue4Single : TVector4Single = ( 0.3, 0.3, 1, 1);`
`LightGreen4Single : TVector4Single = ( 0.3, 1, 0.3, 1);`
`LightCyan4Single : TVector4Single = ( 0.3, 1, 1, 1);`
`LightRed4Single : TVector4Single = ( 1, 0.3, 0.3, 1);`
`LightMagenta4Single : TVector4Single = ( 1, 0.3, 1, 1);`
`Yellow4Single : TVector4Single = ( 1, 1, 0.3, 1);`
`White4Single : TVector4Single = ( 1, 1, 1, 1);`
## Description ### Functions and Procedures
`function GrayscaleValue(const v: TVector3Single): Single; overload;`
Calculate color intensity, as for converting color to grayscale.
`function GrayscaleValue(const v: TVector3Double): Double; overload;`
`function GrayscaleValue(const v: TVector3Byte): Byte; overload;`
`function Grayscale(const v: TVector3Single): TVector3Single; overload;`
`function Grayscale(const v: TVector4Single): Tvector4Single; overload;`
`function Grayscale(const v: TVector3Byte): TVector3Byte; 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 ImageConvertToChannelTo1st: 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: TVector3Single): TVector3Single;`
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: TVector3Single): TVector3Single;`
`function RgbToHsv(const Value: TVector3Byte): TVector3Single;`
`function HsvToRgbByte(const Value: TVector3Single): TVector3Byte;`
`function LerpRgbInHsv(const A: Single; const V1, V2: TVector3Single): TVector3Single;`
Given two colors in RGB, interpolate them in HSV space.
`function ColorToHex(const V: TVector4Single): string;`
Change color into a hexadecimal notation of it (like in HTML). Note that version that takes 4-component vector adds the alpha too at the end.
### Types
`TColorModulatorByteFunc = function (const Color: TVector3Byte): TVector3Byte;`
Function that processes RGB colors, used by TCastleImage.ModulateRGB.
### Constants
`Black3Byte : TVector3Byte = ( 0, 0, 0);`
Some colors. 3-item colors are in RGB format, 4-item colors have additional 4th component always at maximum (1.0 for floats, 255 for bytes etc.)
`Red3Byte : TVector3Byte = (255, 0, 0);`
`Green3Byte : TVector3Byte = ( 0, 255, 0);`
`Blue3Byte : TVector3Byte = ( 0, 0, 255);`
`White3Byte : TVector3Byte = (255, 255, 255);`
`Black4Byte : TVector4Byte = ( 0, 0, 0, 255);`
`Red4Byte : TVector4Byte = (255, 0, 0, 255);`
`Green4Byte : TVector4Byte = ( 0, 255, 0, 255);`
`Blue4Byte : TVector4Byte = ( 0, 0, 255, 255);`
`White4Byte : TVector4Byte = (255, 255, 255, 255);`
`Black3Single : TVector3Single = ( 0, 0, 0);`
Standard 16 colors.
`Blue3Single : TVector3Single = ( 0, 0, 0.6);`
`Green3Single : TVector3Single = ( 0, 0.6, 0);`
`Cyan3Single : TVector3Single = ( 0, 0.6, 0.6);`
`Red3Single : TVector3Single = ( 0.6, 0, 0);`
`Magenta3Single : TVector3Single = ( 0.6, 0, 0.6);`
`Brown3Single : TVector3Single = ( 0.6, 0.3, 0);`
`LightGray3Single : TVector3Single = ( 0.6, 0.6, 0.6);`
`DarkGray3Single : TVector3Single = ( 0.3, 0.3, 0.3);`
`LightBlue3Single : TVector3Single = ( 0.3, 0.3, 1);`
`LightGreen3Single : TVector3Single = ( 0.3, 1, 0.3);`
`LightCyan3Single : TVector3Single = ( 0.3, 1, 1);`
`LightRed3Single : TVector3Single = ( 1, 0.3, 0.3);`
`LightMagenta3Single : TVector3Single = ( 1, 0.3, 1);`
`Yellow3Single : TVector3Single = ( 1, 1, 0.3);`
`White3Single : TVector3Single = ( 1, 1, 1);`
`Gray3Single : TVector3Single = ( 0.5, 0.5, 0.5);`
Some additional colors.
`DarkGreen3Single : TVector3Single = ( 0, 0.3, 0);`
`DarkBrown3Single : TVector3Single = (0.63, 0.15, 0);`
`Orange3Single : TVector3Single = ( 1, 0.5, 0);`
`Black4Single : TVector4Single = ( 0, 0, 0, 1);`
4-components versions of 3Single colors above. Just for your comfort (and some small speed gain sometimes), as opposed to calling Vector4Single(Xxx3Single) all the time.
`Blue4Single : TVector4Single = ( 0, 0, 0.6, 1);`
`Green4Single : TVector4Single = ( 0, 0.6, 0, 1);`
`Cyan4Single : TVector4Single = ( 0, 0.6, 0.6, 1);`
`Red4Single : TVector4Single = ( 0.6, 0, 0, 1);`
`Magenta4Single : TVector4Single = ( 0.6, 0, 0.6, 1);`
`Brown4Single : TVector4Single = ( 0.6, 0.3, 0, 1);`
`LightGray4Single : TVector4Single = ( 0.6, 0.6, 0.6, 1);`
`DarkGray4Single : TVector4Single = ( 0.3, 0.3, 0.3, 1);`
`LightBlue4Single : TVector4Single = ( 0.3, 0.3, 1, 1);`
`LightGreen4Single : TVector4Single = ( 0.3, 1, 0.3, 1);`
`LightCyan4Single : TVector4Single = ( 0.3, 1, 1, 1);`
`LightRed4Single : TVector4Single = ( 1, 0.3, 0.3, 1);`
`LightMagenta4Single : TVector4Single = ( 1, 0.3, 1, 1);`
`Yellow4Single : TVector4Single = ( 1, 1, 0.3, 1);`
`White4Single : TVector4Single = ( 1, 1, 1, 1);`
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:12