AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Blending colors in HSL

Blending colors in HSL

Ein Thema von WojTec · begonnen am 11. Jul 2012 · letzter Beitrag vom 11. Jul 2012
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Blending colors in HSL

  Alt 11. Jul 2012, 11: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 11:16 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von lbccaleb
lbccaleb

Registriert seit: 25. Mai 2006
Ort: Rostock / Bremen
2.037 Beiträge
 
Delphi 7 Enterprise
 
#2

AW: Blending colors in HSL

  Alt 11. Jul 2012, 12:47
Maybe, you get it by yourself when you test the following code

  showmessage(inttostr(Round(255{maxhue/maxsat/maxlum} / 100)));

All Numbers over 85 are to high!
Martin
MFG Caleb
TheSmallOne (MediaPlayer)
Die Dinge werden berechenbar, wenn man die Natur einer Sache durchschaut hat (Blade)

Geändert von lbccaleb (11. Jul 2012 um 12:54 Uhr)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: Blending colors in HSL

  Alt 11. Jul 2012, 15:52
Delphi-Quellcode:
initialization
  MaxHue := 360;
  MaxSat := 100;
  MaxLum := 100;
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)

Edited: for MaxHue=MaxSat=MaxLum=256 is ok. I did right?

And what about other range (default I have 360:100:100)?

Geändert von WojTec (11. Jul 2012 um 15:57 Uhr)
  Mit Zitat antworten Zitat
freeway

Registriert seit: 11. Jul 2009
57 Beiträge
 
Delphi XE Professional
 
#4

AW: Blending colors in HSL

  Alt 11. Jul 2012, 16:05
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 ?
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: Blending colors in HSL

  Alt 11. Jul 2012, 17:12
Oh, of course, will be 1 * percent = percent

Because I want to get colors from HSL circle bethween these 2 colors, not just blend 2 paints
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz