2018-05-08 05:07:54 +03:00
|
|
|
<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="c" x1="10" x2="10" y1="10" y2="310" gradientTransform="matrix(.04 0 0 .0433 1.6 -14.4)" gradientUnits="userSpaceOnUse"><stop stop-color="#7F7F7F" stop-opacity="0" offset="0"/><stop stop-color="#fff" offset="1"/></linearGradient><linearGradient id="d" x1="10" x2="310" y1="10" y2="10" gradientTransform="matrix(.04 0 0 .0433 1.6 -14.4)" gradientUnits="userSpaceOnUse"><stop stop-color="#F00" offset="0"/><stop stop-color="#FF0" offset=".167"/><stop stop-color="#0F0" offset=".333"/><stop stop-color="#0FF" offset=".5"/><stop stop-color="#00F" offset=".667"/><stop stop-color="#F0F" offset=".833"/><stop stop-color="#F00" offset="1"/></linearGradient></defs><script type="text/javascript">var h = 0, s = 100, l = 50, Cr = 255, Cg = 0, Cb = 0;
|
2014-09-11 22:50:03 +10:00
|
|
|
var arrastarHS = false, arrastarL = false;
|
|
|
|
function $(id) { return document.getElementById(id); }
|
|
|
|
function inic() {
|
2018-05-08 05:07:54 +03:00
|
|
|
$("doc").onmousemove = retornar;
|
|
|
|
$("doc").onmousedown = function(event) {
|
2014-09-11 22:50:03 +10:00
|
|
|
var x = event.clientX - 10, y = event.clientY - 10;
|
|
|
|
if(x > 0 && x < 300 && y > 0 && y < 300) arrastarHS = true;
|
|
|
|
if(x > 310 && x < 350 && y > 0 && y < 300) arrastarL = true;
|
|
|
|
}
|
2018-05-08 05:07:54 +03:00
|
|
|
$("doc").onmouseup = function() { arrastarHS = arrastarL = false; }
|
|
|
|
$("doc").onmouseout = function() { arrastarHS = arrastarL = false; }
|
2014-09-11 22:50:03 +10:00
|
|
|
}
|
|
|
|
function retornar(event) {
|
|
|
|
var x = event.clientX - 10;
|
|
|
|
var y = event.clientY - 10;
|
2018-05-08 05:07:54 +03:00
|
|
|
if(x > 0 && x < 300 && y > 0 && y < 300) $("doc").style.cursor = "crosshair";
|
|
|
|
else $("doc").style.cursor = "auto";
|
2014-09-11 22:50:03 +10:00
|
|
|
if(arrastarHS) {
|
|
|
|
if(x < 0) x = 0;
|
|
|
|
else if(x > 300) x = 300;
|
|
|
|
if(y < 0) y = 0;
|
|
|
|
else if(y > 300) y = 300;
|
|
|
|
h = Math.round(x * 1.2);
|
|
|
|
s = Math.round(-(y / 3) + 100);
|
|
|
|
cor();
|
2018-05-08 05:07:54 +03:00
|
|
|
$("cic").setAttribute("cx", x + 10);
|
|
|
|
$("cic").setAttribute("cy", y + 10);
|
2014-09-11 22:50:03 +10:00
|
|
|
}
|
|
|
|
if(arrastarL) {
|
|
|
|
if(y < 0) y = 0;
|
|
|
|
else if(y > 300) y = 300;
|
|
|
|
l = Math.round(-(y / 3) + 100);
|
|
|
|
quad();
|
2018-05-08 05:07:54 +03:00
|
|
|
$("mar").setAttribute("transform", "translate(0, "+y+")");
|
2014-09-11 22:50:03 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function cor() {
|
|
|
|
var b = h / 60 - 3;
|
|
|
|
if(b < 0) b = 6 + b;
|
|
|
|
Cr = Math.round((b<1||b>5?1:b>2&&b<4?0:b<3?2-b:b-4) * 255);
|
|
|
|
Cg = Math.round((b>1&&b<3?1:b>4?0:b<2?b:4-b) * 255);
|
|
|
|
Cb = Math.round((b>3&&b<5?1:b<2?0:b<4?b-2:6-b) * 255);
|
|
|
|
Cr = Math.round(127.5 + (127.5 - Cr) * s / 100);
|
|
|
|
Cg = Math.round(127.5 + (127.5 - Cg) * s / 100);
|
|
|
|
Cb = Math.round(127.5 + (127.5 - Cb) * s / 100);
|
2018-05-08 05:07:54 +03:00
|
|
|
$("cic").style.fill = $("cor").style.fill = "#" + hex(Cr) + hex(Cg) + hex(Cb);
|
2014-09-11 22:50:03 +10:00
|
|
|
quad();
|
|
|
|
}
|
|
|
|
function quad() {
|
|
|
|
var b = h / 60 - 3;
|
|
|
|
if(b < 0) b = 6 + b;
|
|
|
|
Cr = Math.round((b<1||b>5?1:b>2&&b<4?0:b<3?2-b:b-4) * 255);
|
|
|
|
Cg = Math.round((b>1&&b<3?1:b>4?0:b<2?b:4-b) * 255);
|
|
|
|
Cb = Math.round((b>3&&b<5?1:b<2?0:b<4?b-2:6-b) * 255);
|
|
|
|
Cr = Math.round(127.5 + (127.5 - Cr) * s / 100);
|
|
|
|
Cg = Math.round(127.5 + (127.5 - Cg) * s / 100);
|
|
|
|
Cb = Math.round(127.5 + (127.5 - Cb) * s / 100);
|
|
|
|
Cr = Math.round(l > 50 ? Cr + (l / 50 - 1) * (255 - Cr) : l / 50 * Cr);
|
|
|
|
Cg = Math.round(l > 50 ? Cg + (l / 50 - 1) * (255 - Cg) : l / 50 * Cg);
|
|
|
|
Cb = Math.round(l > 50 ? Cb + (l / 50 - 1) * (255 - Cb) : l / 50 * Cb);
|
2018-05-08 05:07:54 +03:00
|
|
|
$("RGB1").firstChild.nodeValue = Cr;
|
|
|
|
$("RGB2").firstChild.nodeValue = Cg;
|
|
|
|
$("RGB3").firstChild.nodeValue = Cb;
|
|
|
|
$("HSL1").firstChild.nodeValue = h + "º";
|
|
|
|
$("HSL2").firstChild.nodeValue = s + "%";
|
|
|
|
$("HSL3").firstChild.nodeValue = l + "%";
|
|
|
|
$("quad").style.fill = $("HEX").firstChild.nodeValue = "#" + hex(Cr) + hex(Cg) + hex(Cb);
|
2014-09-11 22:50:03 +10:00
|
|
|
}
|
|
|
|
function hex(n) {
|
2018-05-08 05:07:54 +03:00
|
|
|
if(n < 16) return "0" + n.toString(16).toUpperCase();
|
2014-09-11 22:50:03 +10:00
|
|
|
else return n.toString(16).toUpperCase();
|
|
|
|
}
|
2018-05-08 05:07:54 +03:00
|
|
|
window.onload = inic;</script><rect transform="rotate(90)" x="2" y="-14" width="12" height="13" fill="url(#d)"/><rect transform="rotate(90)" x="2" y="-14" width="12" height="13" fill="url(#c)"/><rect x=".497" y="1.5" width="14" height="13" fill="none" stroke="#f9f9f9" stroke-linecap="round" stroke-width=".993"/><rect x=".502" y=".502" width="15" height="15" fill="none" stroke="#999" stroke-linecap="round"/></svg>
|