<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FDrewmutt%2FSwatchGrid</id>
	<title>Module:Sandbox/Drewmutt/SwatchGrid - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FDrewmutt%2FSwatchGrid"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Drewmutt/SwatchGrid&amp;action=history"/>
	<updated>2026-04-20T19:48:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Drewmutt/SwatchGrid&amp;diff=145351&amp;oldid=prev</id>
		<title>imported&gt;Drewmutt at 06:18, 16 December 2017</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Drewmutt/SwatchGrid&amp;diff=145351&amp;oldid=prev"/>
		<updated>2017-12-16T06:18:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function rgbToHsl(r, g, b)&lt;br /&gt;
    r, g, b = r / 255, g / 255, b / 255&lt;br /&gt;
&lt;br /&gt;
    local max, min = math.max(r, g, b), math.min(r, g, b)&lt;br /&gt;
    local hue, sat, level&lt;br /&gt;
&lt;br /&gt;
    level = (max + min) / 2&lt;br /&gt;
&lt;br /&gt;
    if max == min then&lt;br /&gt;
        hue, sat = 0, 0 -- achromatic&lt;br /&gt;
    else&lt;br /&gt;
        local d = max - min&lt;br /&gt;
        if level &amp;gt; 0.5 then sat = d / (2 - max - min) else sat = d / (max + min) end&lt;br /&gt;
        if max == r then&lt;br /&gt;
            hue = (g - b) / d&lt;br /&gt;
            if g &amp;lt; b then hue = hue + 6 end&lt;br /&gt;
        elseif max == g then hue = (b - r) / d + 2&lt;br /&gt;
        elseif max == b then hue = (r - g) / d + 4&lt;br /&gt;
        end&lt;br /&gt;
        hue = hue / 6&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return hue, sat, level&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local tileSizeW&lt;br /&gt;
local tileSizeH&lt;br /&gt;
local tileSpacingW&lt;br /&gt;
local tileSpacingH&lt;br /&gt;
	&lt;br /&gt;
function getSwatchTileString(r, g, b)&lt;br /&gt;
    local divstart = &amp;quot;&amp;lt;div style=&amp;#039;margin-left:&amp;quot;..tileSpacingW..&amp;quot;;margin-right:&amp;quot;..tileSpacingW..&amp;quot;;display:inline-block;width:&amp;quot;..tileSizeW..&amp;quot;;height:&amp;quot;..tileSizeH..&amp;quot;;background-color:HSL(&amp;quot;&lt;br /&gt;
    local divend = &amp;quot;%)&amp;#039;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;quot;&lt;br /&gt;
    local a2, b2, c2 = rgbToHsl(r, g, b)&lt;br /&gt;
    return divstart .. (a2 * 360) .. &amp;quot;,&amp;quot; .. (b2 * 100) .. &amp;quot;%,&amp;quot; .. (c2 * 100) .. divend&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.swatchgrid(frame)&lt;br /&gt;
    local a = frame.args&lt;br /&gt;
    local colors = {}&lt;br /&gt;
    colors[1] = { a[5], a[6], a[7] }&lt;br /&gt;
    colors[2] = { a[8], a[9], a[10] }&lt;br /&gt;
    colors[3] = { a[11], a[12], a[13] }&lt;br /&gt;
    colors[4] = { a[14], a[15], a[16] }&lt;br /&gt;
    colors[5] = { a[17], a[18], a[19] }&lt;br /&gt;
&lt;br /&gt;
	 tileSizeW = a[1]&lt;br /&gt;
	 tileSizeH = a[2]&lt;br /&gt;
	tileSpacingW = a[3]&lt;br /&gt;
	tileSpacingH = a[4]&lt;br /&gt;
    local tiles = 5&lt;br /&gt;
    local hdivide = &amp;quot;&amp;lt;div style=&amp;#039;height:&amp;quot;..tileSpacingH..&amp;quot;&amp;#039;&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;br /&gt;
    local result = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    for i = 1, tiles, 1&lt;br /&gt;
    do&lt;br /&gt;
        local color = colors[i] local h = color[1] local s = color[2] local v = color[3]&lt;br /&gt;
        s = s / 2&lt;br /&gt;
        result = result .. getSwatchTileString(h, s, v)&lt;br /&gt;
    end&lt;br /&gt;
    result = result .. hdivide&lt;br /&gt;
&lt;br /&gt;
    for i = 1, tiles, 1&lt;br /&gt;
    do&lt;br /&gt;
        local color = colors[i] local h = color[1] local s = color[2] local v = color[3]&lt;br /&gt;
        result = result .. getSwatchTileString(h, s, v)&lt;br /&gt;
    end&lt;br /&gt;
    result = result .. hdivide&lt;br /&gt;
&lt;br /&gt;
    for i = 1, tiles, 1&lt;br /&gt;
    do&lt;br /&gt;
        local color = colors[i] local h = color[1] local s = color[2] local v = color[3]&lt;br /&gt;
        v = v / 2&lt;br /&gt;
        result = result .. getSwatchTileString(h, s, v)&lt;br /&gt;
    end&lt;br /&gt;
    result = result .. hdivide&lt;br /&gt;
&lt;br /&gt;
    for i = 1, tiles, 1&lt;br /&gt;
    do&lt;br /&gt;
        local color = colors[i] local h = color[1] local s = color[2] local v = color[3]&lt;br /&gt;
        h = (h + 20) % 360&lt;br /&gt;
        result = result .. getSwatchTileString(h, s, v)&lt;br /&gt;
    end&lt;br /&gt;
    result = result .. hdivide&lt;br /&gt;
&lt;br /&gt;
    for i = 1, tiles, 1&lt;br /&gt;
    do&lt;br /&gt;
        local color = colors[i] local h = color[1] local s = color[2] local v = color[3]&lt;br /&gt;
        h = (h + 40) % 360&lt;br /&gt;
        result = result .. getSwatchTileString(h, s, v)&lt;br /&gt;
    end&lt;br /&gt;
    result = result .. hdivide&lt;br /&gt;
&lt;br /&gt;
    return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Drewmutt</name></author>
	</entry>
</feed>