<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/RGBToHSV?action=history&amp;feed=atom</id>
	<title>RGBToHSV - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/RGBToHSV?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=RGBToHSV&amp;action=history"/>
	<updated>2026-05-18T23:49:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=RGBToHSV&amp;diff=73294&amp;oldid=prev</id>
		<title>Olez14: remove debug line</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=RGBToHSV&amp;diff=73294&amp;oldid=prev"/>
		<updated>2022-01-02T23:54:04Z</updated>

		<summary type="html">&lt;p&gt;remove debug line&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:54, 2 January 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l39&quot;&gt;Line 39:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		h = 0&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		h = 0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	end&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	end&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	print(h)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	if maxColor == 0 then&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	if maxColor == 0 then&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-73292:rev-73294 --&gt;
&lt;/table&gt;</summary>
		<author><name>Olez14</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=RGBToHSV&amp;diff=73292&amp;oldid=prev</id>
		<title>Olez14: Created page with &quot;{{Useful Function}} __NOTOC__ This function convert RGB to HSV color space  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt; string RGBToHSV ( int red, int green, int blue ) &lt;/syntaxhighlight&gt;  ===Required Arguments===  * '''red:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space red] in the color (0-255). * '''green:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space green] in the color (0-255). * '''blue:''' The amount of [http://en.wikipedia.org/wiki/...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=RGBToHSV&amp;diff=73292&amp;oldid=prev"/>
		<updated>2022-01-02T23:46:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function convert RGB to HSV color space  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; string RGBToHSV ( int red, int green, int blue ) &amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments===  * &amp;#039;&amp;#039;&amp;#039;red:&amp;#039;&amp;#039;&amp;#039; The amount of [http://en.wikipedia.org/wiki/RGBA_color_space red] in the color (0-255). * &amp;#039;&amp;#039;&amp;#039;green:&amp;#039;&amp;#039;&amp;#039; The amount of [http://en.wikipedia.org/wiki/RGBA_color_space green] in the color (0-255). * &amp;#039;&amp;#039;&amp;#039;blue:&amp;#039;&amp;#039;&amp;#039; The amount of [http://en.wikipedia.org/wiki/...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function convert RGB to HSV color space&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string RGBToHSV ( int red, int green, int blue )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''red:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space red] in the color (0-255).&lt;br /&gt;
* '''green:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space green] in the color (0-255).&lt;br /&gt;
* '''blue:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space blue] in the color (0-255).&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a hue, saturation and value of HSV color space&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function RGBToHSV(r, g, b)&lt;br /&gt;
	local h, s, v&lt;br /&gt;
	local r = r / 255&lt;br /&gt;
	local g = g / 255&lt;br /&gt;
	local b = b / 255&lt;br /&gt;
	&lt;br /&gt;
	local maxColor = math.max(r, g, b)&lt;br /&gt;
	local minColor = math.min(r, g, b)&lt;br /&gt;
	&lt;br /&gt;
	local difference = maxColor - minColor&lt;br /&gt;
	&lt;br /&gt;
	if r == maxColor then&lt;br /&gt;
		h = (60 * ((g - b)/difference) + 360) % 360;&lt;br /&gt;
	elseif g == maxColor then&lt;br /&gt;
		h = (60 * ((b - r)/difference) + 120) % 360;&lt;br /&gt;
	elseif b == maxColor then&lt;br /&gt;
		h = (60 * ((r - g)/difference) + 240) % 360;&lt;br /&gt;
	else&lt;br /&gt;
		h = 0&lt;br /&gt;
	end&lt;br /&gt;
	print(h)&lt;br /&gt;
	&lt;br /&gt;
	if maxColor == 0 then&lt;br /&gt;
		s = 0&lt;br /&gt;
	else&lt;br /&gt;
		s = (difference/maxColor) * 100;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	v = maxColor * 100;&lt;br /&gt;
	&lt;br /&gt;
	return math.ceil(h), math.floor(s), v&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Olez14&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Olez14</name></author>
	</entry>
</feed>