![]() |
Blending colors in HSL
Delphi-Quellcode:
When ~100% then invalid result. Why?
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; |
AW: Blending colors in HSL
Maybe, you get it by yourself when you test the following code ;)
Delphi-Quellcode:
showmessage(inttostr(Round(255{maxhue/maxsat/maxlum} / 100)));
All Numbers over 85 are to high! |
Re: Blending colors in HSL
Delphi-Quellcode:
You mean should be: MaxHue=MaxSat=MaxLum=255? I tried it and result is also not accurately: R is ok, but GB are not ok (G + 2 and B ok or G + 1 and B + 1) :?
initialization
MaxHue := 360; MaxSat := 100; MaxLum := 100; Edited: for MaxHue=MaxSat=MaxLum=256 is ok. I did right? And what about other range (default I have 360:100:100)? |
AW: Blending colors in HSL
hmm why hsl blend over, i don´t see the benefit to rgb blend methode
ok that don´t explain your question you got MaxHue := 360; MaxSat := 100; MaxLum := 100; 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]; you see the difference ? |
Re: Blending colors in HSL
Oh, of course, will be 1 * percent = percent :-D
Because I want to get colors from HSL circle bethween these 2 colors, not just blend 2 paints :) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:13 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz