Registriert seit: 17. Mai 2007
480 Beiträge
Delphi XE6 Professional
|
Blending colors in HSL
11. Jul 2012, 12:13
Delphi-Quellcode:
function BlendColorsHueCW( const AColor1, AColor2: TColor; const AValue: Byte {0..100}): TColor;
var
RGB: array [0..2] of Byte;
HSL1, HSL2: array [0..2] of Integer;
H, S, L: Integer;
begin
GetRGB(AColor1, RGB[0], RGB[1], RGB[2]);
RGBToHSL( RGB[0], RGB[1], RGB[2], HSL1[0], HSL1[1], HSL1[2]);
GetRGB(AColor2, RGB[0], RGB[1], RGB[2]);
RGBToHSL( RGB[0], RGB[1], RGB[2], HSL2[0], HSL2[1], HSL2[2]);
H := Round((MaxHue / 100) * AValue) * (HSL2[0] - HSL1[0]) shr 8 + HSL1[0];
S := Round((MaxSat / 100) * AValue) * (HSL2[1] - HSL1[1]) shr 8 + HSL1[1];
L := Round((MaxLum / 100) * AValue) * (HSL2[2] - HSL1[2]) shr 8 + HSL1[2];
HSLToRGB(H, S, L, RGB[0], RGB[1], RGB[2]);
Result := SetRGB( RGB[0], RGB[1], RGB[2]);
end;
When ~100% then invalid result. Why?
Geändert von WojTec (11. Jul 2012 um 12:16 Uhr)
|
|
Zitat
|