Dd
Color transfer//16 binary color range RGB format color value conversion between//-------------------------------------//16 binary color values regular expression var reg = /^# ([0-9a-fa-f]{3}| [0-9a-fa-f] {6}) $/;/* rgb color conversion to 16 binary */string.prototype.colorhex = function () { var that = this; if (/^ (rgb| RGB)/.test (that)) { var acolor = that.replace (/(?: \ \ (|\) |rgb| RGB) */g, ""). Split (","); var strhex = "#"; for (var i=0; i<acolor.length; i++) { var hex = number (AColor[i]). ToString (+); if (hex === "0") { hex += hex; } strHex += hex; } if (strhex.length !== 7) { strHex = that; } return strhex; }else if (Reg.test ( That) { var anum = that.replace (/#/, ""). Split ("" ); if (anum.length === 6) { return that; }else if (anum.length === 3) { var numhex = "#"; for (var i=0; i<anum.length; i+=1) { numHex += (Anum[i]+anum[i]); } return numhex; } }else{ return that; }};// ---------------------------------- ---------------/* 16 color into RGB format */string.prototype.colorrgb = function () { var scolor = this.tolowercase (); if (sColor && reg.test (Scolor)) { if (scolor.length === 4) { var sColorNew = "#"; for (var i=1; i<4; i+=1) { scolornew += scolor.slice (I, i+1). Concat (Scolor.slice (i,i+1)); } sColor = sColorNew; } // handling six-bit color values var sColorChange = []; for (var i=1; i<7; i+=2) { scolorchange.push (parseint ("0x" +scolor.slice (i,i+2))); } return "RGB (" + scolorchange.join (",") + " ) "; }else{ return scolor; }};
Here's how to call the above function:
if Lickcolor is RGB Domain , you can switch to Hex Color Field
LinkColor = Linkcolor.colorhex ();
If Lickcolor is a hexadecimal color field, it can be converted to an RGB domain by calling
LinkColor = Linkcolor.colorrgb ();
Hex color and RGB cross-turn