Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32_Blend🞂ColorAlgebraFunction

ColorAlgebra

Color channel arithmetic and Photoshop-style compositing blend mode delegates.

Declaration ​

pascal
function ColorAdd(F, B: TColor32): TColor32;
function ColorSub(F, B: TColor32): TColor32;
function ColorDiv(F, B: TColor32): TColor32;
function ColorModulate(F, B: TColor32): TColor32;
function ColorMax(F, B: TColor32): TColor32;
function ColorMin(F, B: TColor32): TColor32;
function ColorDifference(F, B: TColor32): TColor32;
function ColorAverage(F, B: TColor32): TColor32;
function ColorExclusion(F, B: TColor32): TColor32;
function ColorScale(F, B: TColor32): TColor32;
function ColorScreen(F, B: TColor32): TColor32;
function ColorDodge(F, B: TColor32): TColor32;
function ColorBurn(F, B: TColor32): TColor32;
function BlendColorAdd(F, B: TColor32): TColor32;
function BlendColorModulate(F, B: TColor32): TColor32;

Parameters ​

ParameterTypeDescription
FTColor32Foreground pixel color.
BTColor32Background pixel color.

Returns ​

TypeDescription
TColor32The blended 32-bit ARGB result color.

Description ​

This group of functions implements color channel arithmetic and Photoshop-style compositing blend modes between foreground color F and background color B.

Available Blend Modes ​

NameFormula / OperationDescription
ColorAddmin(255,Fc+Bc)Additive blending with channel saturation.
ColorSubmax(0,Bc−Fc)Subtractive blending with zero clamping.
ColorDivmin(255,(Bcâ‹…255)/Fc)Division of background by foreground.
ColorModulate(Fcâ‹…Bc)/255Multiplicative modulation (darkening).
ColorMaxmax(Fc,Bc)Component-wise maximum color selection.
ColorMinmin(Fc,Bc)Component-wise minimum color selection.
ColorDifference|Fc−Bc|Absolute channel difference.
ColorAverage(Fc+Bc)/2Component-wise average.
ColorExclusionFc+Bc−2⋅Fc⋅Bc255Exclusion blend mode (soft contrast inversion).
ColorScale(Fcâ‹…Bc)/255Scaled multiplication.
ColorScreen255−(255−Fc)(255−Bc)255Screen blend mode (lightening blend).
ColorDodgemin(255,Bc⋅255255−Fc)Color dodge blend mode (brightening).
ColorBurn255−min(255,(255−Bc)⋅255Fc)Color burn blend mode (darkening).
BlendColorAddColorAdd modulated by FaAdditive blending modulated by foreground alpha.
BlendColorModulateColorModulate modulated by FaMultiplicative modulation modulated by foreground alpha.

INFO

All these functions are actually delegates; At startup, Graphics32 binds them to the optimal implementation (Pure Pascal, x86/x64 assembly, or SSE2 vector instructions) supported by the host CPU.

See also ​