📄 colorspace.js
字号:
},"RGB":function(obj,_cf){return _1.fromXYZ(_7["Lab"]["XYZ"](_7["LCHab"]["Lab"](obj),_cf),_cf);},"XYZ":function(obj,_d1){return _7["Lab"]["XYZ"](_7["LCHab"]["Lab"](obj,_d1),_d1);},"xyY":function(obj,_d3){return _7["XYZ"]["xyY"](_7["Lab"]["XYZ"](_7["LCHab"]["Lab"](obj),_d3),_d3);}},"LCHuv":{"CMY":function(obj,_d5){return _1.fromXYZ(_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_d5),_d5).toCmy();},"CMYK":function(obj,_d7){return _1.fromXYZ(_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_d7),_d7).toCmyk();},"HSL":function(obj,_d9){return _1.fromXYZ(_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_d9),_d9).toHsl();},"HSV":function(obj,_db){return _1.fromXYZ(_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_db),_db).toHsv();},"Lab":function(obj,_dd){return _7["XYZ"]["Lab"](_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_dd),_dd);},"LCHab":function(obj,_df){return _7["Lab"]["LCHab"](_7["XYZ"]["Lab"](_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_df),_df),_df);},"Luv":function(obj,_e1){return _7["LCHuv"]["Luv"](obj,_e1);},"RGB":function(obj,_e3){return _1.fromXYZ(_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_e3),_e3);},"XYZ":function(obj,_e5){return _7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_e5);},"xyY":function(obj,_e7){return _7["XYZ"]["xyY"](_7["Luv"]["XYZ"](_7["LCHuv"]["Luv"](obj),_e7),_e7);}},"Luv":{"CMY":function(obj,_e9){return _1.fromXYZ(_7["Luv"]["XYZ"](obj,_e9),_e9).toCmy();},"CMYK":function(obj,_eb){return _1.fromXYZ(_7["Luv"]["XYZ"](obj,_eb),_eb).toCmyk();},"HSL":function(obj,_ed){return _1.fromXYZ(_7["Luv"]["XYZ"](obj,_ed),_ed).toHsl();},"HSV":function(obj,_ef){return _1.fromXYZ(_7["Luv"]["XYZ"](obj,_ef),_ef).toHsv();},"Lab":function(obj,_f1){return _7["XYZ"]["Lab"](_7["Luv"]["XYZ"](obj,_f1),_f1);},"LCHab":function(obj,_f3){return _7["Lab"]["LCHab"](_7["XYZ"]["Lab"](_7["Luv"]["XYZ"](obj,_f3),_f3),_f3);},"LCHuv":function(obj,_f5){return _7["Luv"]["LCHuv"](obj,_f5);},"RGB":function(obj,_f7){return _1.fromXYZ(_7["Luv"]["XYZ"](obj,_f7),_f7);},"XYZ":function(obj,_f9){return _7["Luv"]["XYZ"](obj,_f9);},"xyY":function(obj,_fb){return _7["XYZ"]["xyY"](_7["Luv"]["XYZ"](obj,_fb),_fb);}},"RGB":{"CMY":function(obj,_fd){return obj.toCmy();},"CMYK":function(obj,_ff){return obj.toCmyk();},"HSL":function(obj,_101){return obj.toHsl();},"HSV":function(obj,_103){return obj.toHsv();},"Lab":function(obj,_105){return _7["XYZ"]["Lab"](obj.toXYZ(_105),_105);},"LCHab":function(obj,_107){return _7["LCHab"]["Lab"](_7["XYZ"]["Lab"](obj.toXYZ(_107),_107),_107);},"LCHuv":function(obj,_109){return _7["LCHuv"]["Luv"](_7["XYZ"]["Luv"](obj.toXYZ(_109),_109),_109);},"Luv":function(obj,_10b){return _7["XYZ"]["Luv"](obj.toXYZ(_10b),_10b);},"XYZ":function(obj,_10d){return obj.toXYZ(_10d);},"xyY":function(obj,_10f){return _7["XYZ"]["xyY"](obj.toXYZ(_10f),_10f);}},"XYZ":{"CMY":function(obj,_111){return _1.fromXYZ(obj,_111).toCmy();},"CMYK":function(obj,_113){return _1.fromXYZ(obj,_113).toCmyk();},"HSL":function(obj,_115){return _1.fromXYZ(obj,_115).toHsl();},"HSV":function(obj,_117){return _1.fromXYZ(obj,_117).toHsv();},"Lab":function(obj,_119){return _7["XYZ"]["Lab"](obj,_119);},"LCHab":function(obj,_11b){return _7["Lab"]["LCHab"](_7["XYZ"]["Lab"](obj,_11b),_11b);},"LCHuv":function(obj,_11d){return _7["Luv"]["LCHuv"](_7["XYZ"]["Luv"](obj,_11d),_11d);},"Luv":function(obj,_11f){return _7["XYZ"]["Luv"](obj,_11f);},"RGB":function(obj,_121){return _1.fromXYZ(obj,_121);},"xyY":function(obj,_123){return _7["XYZ"]["xyY"](_1.fromXYZ(obj,_123),_123);}},"xyY":{"CMY":function(obj,_125){return _1.fromXYZ(_7["xyY"]["XYZ"](obj,_125),_125).toCmy();},"CMYK":function(obj,_127){return _1.fromXYZ(_7["xyY"]["XYZ"](obj,_127),_127).toCmyk();},"HSL":function(obj,_129){return _1.fromXYZ(_7["xyY"]["XYZ"](obj,_129),_129).toHsl();},"HSV":function(obj,_12b){return _1.fromXYZ(_7["xyY"]["XYZ"](obj,_12b),_12b).toHsv();},"Lab":function(obj,_12d){return _7["Lab"]["XYZ"](_7["xyY"]["XYZ"](obj,_12d),_12d);},"LCHab":function(obj,_12f){return _7["LCHab"]["Lab"](_7["Lab"]["XYZ"](_7["xyY"]["XYZ"](obj,_12f),_12f),_12f);},"LCHuv":function(obj,_131){return _7["LCHuv"]["Luv"](_7["Luv"]["XYZ"](_7["xyY"]["XYZ"](obj,_131),_131),_131);},"Luv":function(obj,_133){return _7["Luv"]["XYZ"](_7["xyY"]["XYZ"](obj,_133),_133);},"RGB":function(obj,_135){return _1.fromXYZ(_7["xyY"]["XYZ"](obj,_135),_135);},"XYZ":function(obj,_137){return _7["xyY"]["XYZ"](obj,_137);}}};this.whitepoint=function(_138,_139){_139=_139||"10";var x=0,y=0,t=0;if(_4[_139]&&_4[_139][_138]){x=_4[_139][_138].x;y=_4[_139][_138].y;t=_4[_139][_138].t;}else{console.warn("dojox.color.Colorspace::whitepoint: either the observer or the whitepoint name was not found. ",_139,_138);}var wp={x:x,y:y,z:(1-x-y),t:t,Y:1};return this.convert(wp,"xyY","XYZ");};this.tempToWhitepoint=function(t){if(t<4000){console.warn("dojox.color.Colorspace::tempToWhitepoint: can't find a white point for temperatures less than 4000K. (Passed ",t,").");return {x:0,y:0};}if(t>25000){console.warn("dojox.color.Colorspace::tempToWhitepoint: can't find a white point for temperatures greater than 25000K. (Passed ",t,").");return {x:0,y:0};}var t1=t,t2=t*t,t3=t2*t;var ten9=Math.pow(10,9),ten6=Math.pow(10,6),ten3=Math.pow(10,3);if(t<=7000){var x=(-4.607*ten9/t3)+(2.9678*ten6/t2)+(0.09911*ten3/t)+0.2444063;}else{var x=(-2.0064*ten9/t3)+(1.9018*ten6/t2)+(0.24748*ten3/t)+0.23704;}var y=-3*x*x+2.87*x-0.275;return {x:x,y:y};};this.primaries=function(_147){_147=dojo.mixin({profile:"sRGB",whitepoint:"D65",observer:"10",adaptor:"Bradford"},_147||{});var m=[];if(_5[_147.profile]){m=_5[_147.profile].slice(0);}else{console.warn("dojox.color.Colorspace::primaries: the passed profile was not found. ","Available profiles include: ",_5,". The profile passed was ",_147.profile);}var _149={name:_147.profile,gamma:m[0],whitepoint:m[1],xr:m[2],yr:m[3],Yr:m[4],xg:m[5],yg:m[6],Yg:m[7],xb:m[8],yb:m[9],Yb:m[10]};if(_147.whitepoint!=_149.whitepoint){var r=this.convert(this.adapt({color:this.convert({x:xr,y:yr,Y:Yr},"xyY","XYZ"),adaptor:_147.adaptor,source:_149.whitepoint,destination:_147.whitepoint}),"XYZ","xyY");var g=this.convert(this.adapt({color:this.convert({x:xg,y:yg,Y:Yg},"xyY","XYZ"),adaptor:_147.adaptor,source:_149.whitepoint,destination:_147.whitepoint}),"XYZ","xyY");var b=this.convert(this.adapt({color:this.convert({x:xb,y:yb,Y:Yb},"xyY","XYZ"),adaptor:_147.adaptor,source:_149.whitepoint,destination:_147.whitepoint}),"XYZ","xyY");_149=dojo.mixin(_149,{xr:r.x,yr:r.y,Yr:r.Y,xg:g.x,yg:g.y,Yg:g.Y,xb:b.x,yb:b.y,Yb:b.Y,whitepoint:_147.whitepoint});}return dojo.mixin(_149,{zr:1-_149.xr-_149.yr,zg:1-_149.xg-_149.yg,zb:1-_149.xb-_149.yb});};this.adapt=function(_14d){if(!_14d.color||!_14d.source){console.error("dojox.color.Colorspace::adapt: color and source arguments are required. ",_14d);}_14d=dojo.mixin({adaptor:"Bradford",destination:"D65"},_14d);var swp=this.whitepoint(_14d.source);var dwp=this.whitepoint(_14d.destination);if(_6[_14d.adaptor]){var ma=_6[_14d.adaptor].ma;var mai=_6[_14d.adaptor].mai;}else{console.warn("dojox.color.Colorspace::adapt: the passed adaptor '",_14d.adaptor,"' was not found.");}var dSrc=_2.multiply([[swp.x,swp.y,swp.z]],ma);var _153=_2.multiply([[dwp.x,dwp.y,dwp.z]],ma);var _154=[[_153[0][0]/dSrc[0][0],0,0],[0,_153[0][1]/dSrc[0][1],0],[0,0,_153[0][2]/dSrc[0][2]]];var m=_2.multiply(_2.multiply(ma,_154),mai);var r=_2.multiply([[_14d.color.X,_14d.color.Y,_14d.color.Z]],m)[0];return {X:r[0],Y:r[1],Z:r[2]};};this.matrix=function(to,_158){var wp=this.whitepoint(_158.whitepoint);var Xr=p.xr/p.yr,Yr=1,Zr=(1-p.xr-p.yr)/p.yr;var Xg=p.xg/p.yg,Yg=1,Zg=(1-p.xg-p.yg)/p.yg;var Xb=p.xb/p.yb,Yb=1,Zr=(1-p.xb-p.yb)/p.yb;var m1=[[Xr,Yr,Zr],[Xg,Yg,Zg],[Xb,Yb,Zb]];var m2=[[wp.X,wp.Y,wp.Z]];var sm=dojox.math.matrix.multiply(m2,dojox.math.matrix.inverse(m1));var Sr=sm[0][0],Sg=sm[0][1],Sb=sm[0][2];var _168=[[Sr*Xr,Sr*Yr,Sr*Zr],[Sg*Xg,Sg*Yg,Sg*Zg],[Sb*Xb,Sb*Yb,Sb*Zb]];if(to=="RGB"){return dojox.math.inverse(_168);}return _168;};this.epsilon=function(_169){return (_169||typeof (_169)=="undefined")?0.008856:216/24289;};this.kappa=function(_16a){return (_16a||typeof (_16a)=="undefined")?903.3:24389/27;};this.convert=function(_16b,from,to,_16e){if(_5b[from]&&_5b[from][to]){return _5b[from][to](obj,_16e);}console.warn("dojox.color.Colorspace::convert: Can't convert ",_16b," from ",from," to ",to,".");};})();dojo.mixin(dojox.color,{fromXYZ:function(xyz,_170){_170=_170||{};var p=dojox.color.Colorspace.primaries(_170);var m=dojox.color.Colorspace.matrix("RGB",p);var rgb=dojox.math.matrix.mutliply([[xyz.X,xyz.Y,xyz.Z]],m);var r=rgb[0][0],g=rgb[0][1],b=rgb[0][2];if(p.profile=="sRGB"){var R=(r>0.0031308)?(1.055*Math.pow(r,1/2.4))-0.055:12.92*r;var G=(g>0.0031308)?(1.055*Math.pow(g,1/2.4))-0.055:12.92*g;var B=(b>0.0031308)?(1.055*Math.pow(b,1/2.4))-0.055:12.92*b;}else{var R=Math.pow(r,1/p.gamma),G=Math.pow(g,1/p.gamma),B=Math.pow(b,1/p.gamma);}return new dojox.color.Color({r:Math.floor(R*255),g:Math.floor(G*255),b:Math.floor(B*255)});}});dojo.extend(dojox.color.Color,{toXYZ:function(_17a){_17a=_17a||{};var p=dojox.color.Colorspace.primaries(_17a);var m=dojox.color.Colorspace.matrix("XYZ",p);var _r=this.r/255,_g=this.g/255,_b=this.b/255;if(p.profile=="sRGB"){var r=(_r>0.04045)?Math.pow(((_r+0.055)/1.055),2.4):_r/12.92;var g=(_g>0.04045)?Math.pow(((_g+0.055)/1.055),2.4):_g/12.92;var b=(_b>0.04045)?Math.pow(((_b+0.055)/1.055),2.4):_b/12.92;}else{var r=Math.pow(_r,p.gamma),g=Math.pow(_g,p.gamma),b=Math.pow(_b,p.gamma);}var xyz=dojox.math.matrix([[r,g,b]],m);return {X:xyz[0][0],Y:xyz[0][1],Z:xyz[0][2]};}});}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -