| Zitat: |
|
RGB->HSL 1. Skalieren der RBG Werte auf Bereich 0-1 2. minimalen und maximalen Wert finden 3. L = (maxcolor + mincolor)/2 4. If mincolor=maxcolor dann S = 0, H undefiniert (=0) 5. else: if L < 0.5, S=(maxcolor-mincolor)/(maxcolor+mincolor) if L >=0.5, S=(maxcolor-mincolor)/(2.0-maxcolor-mincolor) 6. if R=maxcolor, H = (G-B)/(maxcolor-mincolor) if G=maxcolor, H = 2.0 + (B-R)/(maxcolor-mincolor) if B=maxcolor, H = 4.0 + (R-G)/(maxcolor-mincolor) 7. H = H*60.0; if H < 0 dann H=H+360; 8. S=S*100; L=L*100; Anschließend ist H der Winkel im Farbkreis, S und L geben in Prozent die Sättigung und Leuchtkraft an. HSL->RGB 1. if S=0, dann R=L, G=L und B=L; 2. else: If L < 0.5, temp2=L*(1.0+S) If L >= 0.5, temp2=L+S - L*S temp1 = 2.0*L - temp2 3. skaliere H in den Bereich zwischen 0-1 4. für jeden der Farbwerte (R,G,B) lege eine eigene temporäre Variable, temp3, an: für R, temp3=H+1.0/3.0 für G, temp3=H für B, temp3=H-1.0/3.0 if temp3 < 0, temp3 = temp3 + 1.0 if temp3 > 1, temp3 = temp3 - 1.0 5. Für je R,G,B: if 6.0*temp3 < 1, color=temp1+(temp2-temp1)*6.0*temp3 else if 2.0*temp3 < 1, color=temp2 else if 3.0*temp3 < 2, color=temp1+(temp2-temp1)*((2.0/3.0)- temp3)*6.0 else color=temp1 6. Zurückskalieren auf Bereich 0-256 |
1: | procedure RGBtoHSL (R,G,B: double; var H, S, L : double); |
1: | unit HSLUtility; |
Entwickler-Ecke.de based on phpBB
Copyright 2002 - 2011 by Tino Teuber, Copyright 2011 - 2026 by Christian Stelzmann Alle Rechte vorbehalten.
Alle Beiträge stammen von dritten Personen und dürfen geltendes Recht nicht verletzen.
Entwickler-Ecke und die zugehörigen Webseiten distanzieren sich ausdrücklich von Fremdinhalten jeglicher Art!