Difference between revisions of "HSV color"
m (Remove sentence fragment ", note that") |
|||
Line 5: | Line 5: | ||
*'''Value''' is how saturated an image is, the amount of each color. | *'''Value''' is how saturated an image is, the amount of each color. | ||
− | This function converts HSV values to RGB | + | This function converts HSV values to RGB: |
<source lang="lua"> | <source lang="lua"> | ||
-- Converts HSV to RGB. (input and output range: 0 - 255) | -- Converts HSV to RGB. (input and output range: 0 - 255) |
Revision as of 19:07, 2 October 2011
The HSV color space is based on how humans perceive color, and as such, makes various aesthetically-pleasing color transformations very simple.
- Hue describes where in the spectrum the color is. As Hue increases, a color will transition in the following order: Red, orange, yellow, green, teal, blue, violet, purple, magenta, red.
- Saturation denotes how vibrant a color is. Ranges from grey to pure color.
- Value is how saturated an image is, the amount of each color.
This function converts HSV values to RGB:
-- Converts HSV to RGB. (input and output range: 0 - 255)
function HSV(h, s, v)
if s <= 0 then return v,v,v end
h, s, v = h/256*6, s/255, v/255
local c = v*s
local x = (1-math.abs((h%2)-1))*c
local m,r,g,b = (v-c), 0,0,0
if h < 1 then r,g,b = c,x,0
elseif h < 2 then r,g,b = x,c,0
elseif h < 3 then r,g,b = 0,c,x
elseif h < 4 then r,g,b = 0,x,c
elseif h < 5 then r,g,b = x,0,c
else r,g,b = c,0,x
end return (r+m)*255,(g+m)*255,(b+m)*255
end
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info