<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ko">
	<id>https://wiki.theeum.com/index.php?action=history&amp;feed=atom&amp;title=%EB%AA%A8%EB%93%88%3AHSV</id>
	<title>모듈:HSV - 편집 역사</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.theeum.com/index.php?action=history&amp;feed=atom&amp;title=%EB%AA%A8%EB%93%88%3AHSV"/>
	<link rel="alternate" type="text/html" href="https://wiki.theeum.com/index.php?title=%EB%AA%A8%EB%93%88:HSV&amp;action=history"/>
	<updated>2026-06-02T22:23:14Z</updated>
	<subtitle>이 문서의 편집 역사</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://wiki.theeum.com/index.php?title=%EB%AA%A8%EB%93%88:HSV&amp;diff=8770&amp;oldid=prev</id>
		<title>HyunJongSu: &quot;모듈:HSV&quot; 문서를 보호했습니다 ([편집=관리자만 허용] (무기한) [이동=관리자만 허용] (무기한))</title>
		<link rel="alternate" type="text/html" href="https://wiki.theeum.com/index.php?title=%EB%AA%A8%EB%93%88:HSV&amp;diff=8770&amp;oldid=prev"/>
		<updated>2023-06-03T16:19:19Z</updated>

		<summary type="html">&lt;p&gt;&amp;quot;&lt;a href=&quot;/wiki/%EB%AA%A8%EB%93%88:HSV&quot; title=&quot;모듈:HSV&quot;&gt;모듈:HSV&lt;/a&gt;&amp;quot; 문서를 보호했습니다 ([편집=관리자만 허용] (무기한) [이동=관리자만 허용] (무기한))&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ko&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 이전 판&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2023년 6월 4일 (일) 01:19 판&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ko&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(차이 없음)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>HyunJongSu</name></author>
	</entry>
	<entry>
		<id>https://wiki.theeum.com/index.php?title=%EB%AA%A8%EB%93%88:HSV&amp;diff=8769&amp;oldid=prev</id>
		<title>HyunJongSu: 새 문서: local p = {}  function rgb2hsv(r, g, b)     local max = math.max(r, g, b)     local min = math.min(r, g, b)     local c = max - min          -- calculate hue     local h     if c == 0 then         h = 0     elseif max == r then         h = 60 * (0 + ((g - b)/c))     elseif max == g then         h = 60 * (2 + ((b - r)/c))     elseif max == b then         h = 60 * (4 + ((r - g)/c))     end     if h &lt; 0 then h = h + 360 end          -- calculate value     local v = max          --...</title>
		<link rel="alternate" type="text/html" href="https://wiki.theeum.com/index.php?title=%EB%AA%A8%EB%93%88:HSV&amp;diff=8769&amp;oldid=prev"/>
		<updated>2023-06-03T16:19:11Z</updated>

		<summary type="html">&lt;p&gt;새 문서: local p = {}  function rgb2hsv(r, g, b)     local max = math.max(r, g, b)     local min = math.min(r, g, b)     local c = max - min          -- calculate hue     local h     if c == 0 then         h = 0     elseif max == r then         h = 60 * (0 + ((g - b)/c))     elseif max == g then         h = 60 * (2 + ((b - r)/c))     elseif max == b then         h = 60 * (4 + ((r - g)/c))     end     if h &amp;lt; 0 then h = h + 360 end          -- calculate value     local v = max          --...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;새 문서&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
function rgb2hsv(r, g, b)&lt;br /&gt;
    local max = math.max(r, g, b)&lt;br /&gt;
    local min = math.min(r, g, b)&lt;br /&gt;
    local c = max - min&lt;br /&gt;
    &lt;br /&gt;
    -- calculate hue&lt;br /&gt;
    local h&lt;br /&gt;
    if c == 0 then&lt;br /&gt;
        h = 0&lt;br /&gt;
    elseif max == r then&lt;br /&gt;
        h = 60 * (0 + ((g - b)/c))&lt;br /&gt;
    elseif max == g then&lt;br /&gt;
        h = 60 * (2 + ((b - r)/c))&lt;br /&gt;
    elseif max == b then&lt;br /&gt;
        h = 60 * (4 + ((r - g)/c))&lt;br /&gt;
    end&lt;br /&gt;
    if h &amp;lt; 0 then h = h + 360 end&lt;br /&gt;
    &lt;br /&gt;
    -- calculate value&lt;br /&gt;
    local v = max&lt;br /&gt;
    &lt;br /&gt;
    -- calculate luminance&lt;br /&gt;
    -- local l = (max + min) / 2&lt;br /&gt;
    &lt;br /&gt;
    -- calculate saturation&lt;br /&gt;
    local s&lt;br /&gt;
    if c == 0 then&lt;br /&gt;
        s = 0&lt;br /&gt;
    else&lt;br /&gt;
        s = c/v&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    return h, s, v&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function hsv2rgb(h, s, v)&lt;br /&gt;
    local hi = math.floor(h / 60)&lt;br /&gt;
    local f = ((h / 60) - hi)&lt;br /&gt;
    &lt;br /&gt;
    local p = v * (1 - s)&lt;br /&gt;
    local q = v * (1 - s * f)&lt;br /&gt;
    local t = v * (1 - s * (1 - f))&lt;br /&gt;
    &lt;br /&gt;
    if hi == 1 then&lt;br /&gt;
        return q, v, p&lt;br /&gt;
    elseif hi == 2 then&lt;br /&gt;
        return p, v, t&lt;br /&gt;
    elseif hi == 3 then&lt;br /&gt;
        return p, q, v&lt;br /&gt;
    elseif hi == 4 then&lt;br /&gt;
        return t, p, v&lt;br /&gt;
    elseif hi == 5 then&lt;br /&gt;
        return v, p, q&lt;br /&gt;
    else&lt;br /&gt;
        return v, t, p&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function decodeRGBHex(rgb)&lt;br /&gt;
    local r = string.sub(rgb, 1, 2)&lt;br /&gt;
    local g = string.sub(rgb, 3, 4)&lt;br /&gt;
    local b = string.sub(rgb, 5, 6)&lt;br /&gt;
    return tonumber(r, 16), tonumber(g, 16), tonumber(b, 16)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function getRGB(args)&lt;br /&gt;
    local r, g, b, i&lt;br /&gt;
    if string.len(args[1]) == 6 then&lt;br /&gt;
        r, g, b = decodeRGBHex(args[1])&lt;br /&gt;
        i = 2&lt;br /&gt;
    else&lt;br /&gt;
        r = args[1]&lt;br /&gt;
        g = args[2]&lt;br /&gt;
        b = args[3]&lt;br /&gt;
        i = 4&lt;br /&gt;
    end&lt;br /&gt;
    return r / 255, g / 255, b / 255, i&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[toHSV&lt;br /&gt;
Description: Converts a RGB color to a HSV color.&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:HSV|toHSV|R|G|B}} or {{#invoke:HSV|toHSV|RGBhex}}&lt;br /&gt;
&lt;br /&gt;
Output: hue [0°..360°]/saturation [0..1]/value [0..1]&lt;br /&gt;
]]&lt;br /&gt;
function p.toHSV(frame)&lt;br /&gt;
    local r, g, b = getRGB(frame.args)&lt;br /&gt;
    local h, s, v = rgb2hsv(r, g, b)&lt;br /&gt;
    return h .. &amp;quot;/&amp;quot; .. s .. &amp;quot;/&amp;quot; .. v&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[hue&lt;br /&gt;
Description: Returns the hue of a RGB color.&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:HSV|hue|R|G|B}} or {{#invoke:HSV|hue|RGBhex}}&lt;br /&gt;
&lt;br /&gt;
Output: hue [0°..360°]&lt;br /&gt;
]]&lt;br /&gt;
function p.hue(frame)&lt;br /&gt;
    local r, g, b = getRGB(frame.args)&lt;br /&gt;
    local h, s, v = rgb2hsv(r, g, b)&lt;br /&gt;
    return h&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[saturation&lt;br /&gt;
Description: Returns the saturation of a RGB color.&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:HSV|saturation|R|G|B}} or {{#invoke:HSV|saturation|RGBhex}}&lt;br /&gt;
&lt;br /&gt;
Output: saturation [0..1]&lt;br /&gt;
]]&lt;br /&gt;
function p.saturation(frame)&lt;br /&gt;
    local r, g, b = getRGB(frame.args)&lt;br /&gt;
    local h, s, v = rgb2hsv(r, g, b)&lt;br /&gt;
    return s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[value&lt;br /&gt;
Description: Returns the hue of a RGB color.&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:HSV|value|R|G|B}} or {{#invoke:HSV|value|RGBhex}}&lt;br /&gt;
&lt;br /&gt;
Output: value [0..1]&lt;br /&gt;
]]&lt;br /&gt;
function p.value(frame)&lt;br /&gt;
    local r, g, b = getRGB(frame.args)&lt;br /&gt;
    local h, s, v = rgb2hsv(r, g, b)&lt;br /&gt;
    return v&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[saturate&lt;br /&gt;
Description: Saturates a RGB color by a given factor.&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:HSV|saturate|R|G|B|factor}} or {{#invoke:HSV|saturate|RGBhex|factor}}&lt;br /&gt;
Optionally &amp;quot;factor&amp;quot; can be followed by another parameter with the value &amp;quot;hex&amp;quot; can be given to return the RGB color in a hexadecimal representation.&lt;br /&gt;
&lt;br /&gt;
Output: saturated RGB&lt;br /&gt;
]]&lt;br /&gt;
function p.saturate(frame)&lt;br /&gt;
    local r, g, b, i = getRGB(frame.args)&lt;br /&gt;
    -- convert to HSV&lt;br /&gt;
    local h, s, v = rgb2hsv(r, g, b)&lt;br /&gt;
    -- saturate&lt;br /&gt;
    s = s * frame.args[i]&lt;br /&gt;
    if s &amp;lt; 0 then&lt;br /&gt;
        s = 0&lt;br /&gt;
    elseif s &amp;gt; 1 then&lt;br /&gt;
        s = 1&lt;br /&gt;
    end&lt;br /&gt;
    -- convert back to RGB&lt;br /&gt;
    local r, g, b = hsv2rgb(h, s, v)&lt;br /&gt;
    r = math.floor(r * 255 + 0.5)&lt;br /&gt;
    g = math.floor(g * 255 + 0.5)&lt;br /&gt;
    b = math.floor(b * 255 + 0.5)&lt;br /&gt;
    -- return values&lt;br /&gt;
    if frame.args[i + 1] == &amp;quot;hex&amp;quot; then&lt;br /&gt;
        return string.format(&amp;quot;%.2X%.2X%.2X&amp;quot;, r, g, b)&lt;br /&gt;
    else&lt;br /&gt;
        return r .. &amp;quot;/&amp;quot; .. g .. &amp;quot;/&amp;quot; .. b&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[toRGB&lt;br /&gt;
Description: Converts a HSV color to a RGB color.&lt;br /&gt;
&lt;br /&gt;
Usage: {{#invoke:HSV|toRGB|H|S|V}} with H in [0°..360°], S in [0..1] and V in [0..1].&lt;br /&gt;
Optionally a 4th parameter with the value &amp;quot;hex&amp;quot; can be given to return the RGB color in a hexadecimal representation.&lt;br /&gt;
&lt;br /&gt;
Output: R/G/B&lt;br /&gt;
]]&lt;br /&gt;
function p.toRGB(frame)&lt;br /&gt;
    local r, g, b = hsv2rgb(frame.args[1], frame.args[2], frame.args[3])&lt;br /&gt;
    -- transform from real [0..1] to integer [0..255]&lt;br /&gt;
    r = math.floor(r * 255 + 0.5)&lt;br /&gt;
    g = math.floor(g * 255 + 0.5)&lt;br /&gt;
    b = math.floor(b * 255 + 0.5)&lt;br /&gt;
    -- return values&lt;br /&gt;
    if frame.args[4] == &amp;quot;hex&amp;quot; then&lt;br /&gt;
        return string.format(&amp;quot;%.2X%.2X%.2X&amp;quot;, r, g, b)&lt;br /&gt;
    else&lt;br /&gt;
        return r .. &amp;quot;/&amp;quot; .. g .. &amp;quot;/&amp;quot; .. b&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>HyunJongSu</name></author>
	</entry>
</feed>