Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
HSL and HSV
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===== HSL to RGB alternative ===== The polygonal piecewise functions can be somewhat simplified by clever use of minimum and maximum values as well as the remainder operation. Given a color with hue <math>H \in [0^\circ,360^\circ]</math>, saturation <math>S=S_L \in [0,1]</math>, and lightness <math>L \in [0,1]</math>, we first define the function: : <math>f(n) = L - a \max(-1, \min(k-3,9-k,1))</math> where <math>k,n \in \mathbb R_{\geq 0}</math> and: : <math>k = \left(n+\frac{H}{30^\circ}\right) \bmod 12</math> : <math>a = S_L \min(L,1-L)</math> And output R,G,B values (from <math>[0,1]^3</math>) are: : <math>(R,G,B) = (f(0), f(8), f(4))</math> The above alternative formulas allow for shorter implementations. In the above formulas the <math>a\bmod b</math> operation also returns the fractional part of the module e.g. <math> 7.4 \bmod 6 = 1.4</math>, and <math>k \in [0,12)</math>. The base shape <math>T(k) = t(n,H) = \max(\min(k-3,9-k,1), -1)</math> is constructed as follows: <math>t_1 = \min(k-3,9-k)</math> is a "triangle" for which values greater or equal to β1 start from k=2 and end at k=10, and the highest point is at k=6. Then by <math>t_2 = \min(t_1,1) = \min(k-3,9-k,1)</math> we change values bigger than 1 to equal 1. Then by <math>t = \max(t_2,-1)</math> we change values less than β1 to equal β1. At this point, we get something similar to the red shape from fig. 24 after a vertical flip (where the maximum is 1 and the minimum is β1). The R,G,B functions of {{mvar|H}} use this shape transformed in the following way: modulo-shifted on {{mvar|X}} (by {{mvar|n}}) (differently for R,G,B) scaled on {{mvar|Y}} (by <math>-a</math>) and shifted on {{mvar|Y}} (by {{mvar|L}}). We observe the following shape properties (Fig. 24 can help to get an intuition about them): : <math>t(n,H) = -t(n+6,H)</math> : <math>\min\ (t(n,H), t(n+4,H), t(n+8,H)) = -1</math> : <math>\max\ (t(n,H), t(n+4,H), t(n+8,H)) = +1</math>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)