Color Mode conversion function

Source: Internet
Author: User
Tags min
function Hextorgb (hex) ... {
Hex = Hex.touppercase ();
if (Hex.charat (0) = = "#") hex = hex.substring (1,hex.length);
var rgb = new Array (3);
RGB.R = hex.substring (0,2);
RGB.G = hex.substring (2,4);
rgb.b = hex.substring (4,6);
RGB.R = parseint (rgb.r,16);
RGB.G = parseint (rgb.g,16);
rgb.b = parseint (rgb.b,16);
if (IsNaN (RGB.R)) RGB.R = 0;
if (IsNaN (RGB.G)) RGB.G = 0;
if (IsNaN (rgb.b)) rgb.b = 0;
return RGB;
}
function Rgbtohex (R, G, B) ... {
var n = math.round (B);
n + = Math.Round (G) << 8;
n + = Math.Round (R) << 16;
return DectoHex (n);
}
Turns decimal integer (e.g., bgColor) into hexadecimal string
function DectoHex (num) ... {
var i = 0; var j = 20;
var str = "#";
while (J >= 0) ... {
i = (num >> j)%16;
if (i >= 10) ... {
if (i = =) str + = "A";
else if (i = =) str + = "B";
else if (i = =) str + = "C";
else if (i = =) str + = "D";
else if (i = =) str + = "E";
else str + = "F";
} else
str + = i;
J-= 4;
}
return str;
}
function MIN () ... {
var min = 255;
for (var i = 0; i < arguments.length; i++)
if (Arguments[i] < min)
min = arguments[i];
return min;
}
function MAX () ... {
var max = 0;
for (var i = 0; i < arguments.length; i++)
if (Arguments[i] > Max)
max = Arguments[i];
return Max;
}
function Rgbtocmyk (r,g,b) ... {//doesn ' t distort! not really usable ...
R/= 255;
&

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.