;(function ($) {$. Smcolor={rgbint2rgb:function (rgbint) {return{red: (Rgbint>> -) &255, Green: (Rgbint>>8) &255, Blue:rgbint&255 }; }, Rgbint2hex:function (rgbint) {varcolor = This. Rgbint2rgb (Rgbint); return This. Rgb2hex (Color.Red, Color.green, Color.Blue); }, Rgb2hex:function (red, green, blue) {return "#"+ ((1<< -) + (Red << -) + (Green <<8) + blue). ToString ( -). Slice (1); }, Rgb2rgbint:function (red, green, blue) {return(Red << -) + (Green <<8) +blue); }, Hex2rgb:function (hexstr) {//Hexstr must be in the #rrggbb format varHex = parseint (hexstr.substring (1), -); return{red: (Hex&0xff0000) >> -, Green: (Hex&0x00ff00) >>8, Blue:hex&0x0000ff }; }, Hex2rgbint:function (hexstr) {//Hexstr must be in the #rrggbb format varcolor = This. Hex2rgb (HEXSTR); return This. Rgb2rgbint (Color.Red, Color.green, Color.Blue); }, Rgbobj2htm:function (rgbobj) {return "RGB ("+ rgbobj.red +", "+ Rgbobj.green +", "+ Rgbobj.blue +")"; } }; }) (JQuery); $ (function () {Console.log ("Rgbint2rgb (16711680):"+ $. Smcolor.rgbobj2htm ($. Smcolor.rgbint2rgb (16711680))); Console.log ("Rgbint2hex (16711680):"+ $. Smcolor.rgbint2hex (16711680)); Console.log ("Rgb2hex (255,0,0):"+ $. Smcolor.rgb2hex (255,0,0)); Console.log ("Rgb2rgbint (255,0,0):"+ $. Smcolor.rgb2rgbint (255,0,0)); Console.log ("Hex2rgb (' #ff0000 '):"+ $. Smcolor.rgbobj2htm ($. Smcolor.hex2rgb ("#ff0000"))); Console.log ("hex2rgbint (' #ff0000 '):"+ $. Smcolor.hex2rgbint ("#ff0000")); }); output://Rgbint2rgb (16711680): RGB (255, 0, 0)//Rgbint2hex (16711680): #ff0000//Rgb2hex (255,0,0): #ff0000//Rgb2rgbint (255,0,0): 16711680//Hex2rgb (' #ff0000 '): RGB (255, 0, 0)//hex2rgbint (' #ff0000 '): 16711680
Jquery rgbint RGB Hex cross-turn