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!
===== HSV to RGB alternative ===== Given a color with hue <math>H \in [0^\circ,360^\circ]</math>, saturation <math>S=S_V \in [0,1]</math>, and value <math>V \in [0,1]</math>, first we define function : : <math>f(n) = V - VS \max(0, \min(k, 4-k, 1))</math> where <math>k,n \in \mathbb R_{\geq 0}</math> and: : <math>k = \left(n+\frac{H}{60^\circ}\right) \bmod 6</math> And output R,G,B values (from <math>[0,1]^3</math>) are: : <math>(R,G,B) = (f(5), f(3), f(1))</math> Above alternative equivalent formulas allow shorter implementation. In above formulas the <math>a\bmod b</math> returns also fractional part of module e.g. the formula <math> 7.4 \bmod 6 = 1.4</math>. The values of <math>k \in \mathbb R \land k \in [0,6)</math>. The base shape : <math>t(n,H) = T(k) = \max(0, \min(k, 4-k, 1))</math> is constructed as follows: <math>t_1 = \min(k,4-k)</math> is "triangle" for which non-negative values starts from k=0, highest point at k=2 and "ends" at k=4, then we change values bigger than one to one by <math>t_2 = \min(t_1,1) = \min(k,4-k,1)</math>, then change negative values to zero by <math>t = \max(t2,0)</math> β and we get (for <math>n=0</math>) something similar to green shape from Fig. 24 (which max value is 1 and min value is 0). The R,G,B functions of {{mvar|H}} use this shape transformed in following way: modulo-shifted on {{mvar|X}} (by {{mvar|n}}) (differently for R,G,B) scaled on {{mvar|Y}} (by <math>-VS</math>) and shifted on {{mvar|Y}} (by {{mvar|V}}). We observe following shape properties(Fig. 24 can help to get intuition about this): : <math>t(n,H) = 1-t(n+3,H)</math> : <math>\min(t(n,H), t(n+2,H), t(n+4,H)) = 0</math> : <math>\max(t(n,H), t(n+2,H), t(n+4,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)