📄 silverlight.js
字号:
/* Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details*/if(!dojo._hasResource["dojox.gfx.silverlight"]){dojo._hasResource["dojox.gfx.silverlight"]=true;dojo.provide("dojox.gfx.silverlight");dojo.require("dojox.gfx._base");dojo.require("dojox.gfx.shape");dojo.require("dojox.gfx.path");dojo.experimental("dojox.gfx.silverlight");dojox.gfx.silverlight.dasharray={solid:"none",shortdash:[4,1],shortdot:[1,1],shortdashdot:[4,1,1,1],shortdashdotdot:[4,1,1,1,1,1],dot:[1,3],dash:[4,3],longdash:[8,3],dashdot:[4,3,1,3],longdashdot:[8,3,1,3],longdashdotdot:[8,3,1,3,1,3]};dojox.gfx.silverlight.fontweight={normal:400,bold:700};dojox.gfx.silverlight.caps={butt:"Flat",round:"Round",square:"Square"};dojox.gfx.silverlight.joins={bevel:"Bevel",round:"Round"};dojox.gfx.silverlight.fonts={serif:"Times New Roman",times:"Times New Roman","sans-serif":"Arial",helvetica:"Arial",monotone:"Courier New",courier:"Courier New"};dojox.gfx.silverlight.hexColor=function(_1){var c=dojox.gfx.normalizeColor(_1),t=c.toHex(),a=Math.round(c.a*255);a=(a<0?0:a>255?255:a).toString(16);return "#"+(a.length<2?"0"+a:a)+t.slice(1);};dojo.extend(dojox.gfx.Shape,{setFill:function(_5){var p=this.rawNode.getHost().content,r=this.rawNode,f;if(!_5){this.fillStyle=null;this._setFillAttr(null);return this;}if(typeof (_5)=="object"&&"type" in _5){switch(_5.type){case "linear":this.fillStyle=f=dojox.gfx.makeParameters(dojox.gfx.defaultLinearGradient,_5);var _9=p.createFromXaml("<LinearGradientBrush/>");_9.mappingMode="Absolute";_9.startPoint=f.x1+","+f.y1;_9.endPoint=f.x2+","+f.y2;dojo.forEach(f.colors,function(c){var t=p.createFromXaml("<GradientStop/>");t.offset=c.offset;t.color=dojox.gfx.silverlight.hexColor(c.color);_9.gradientStops.add(t);});this._setFillAttr(_9);break;case "radial":this.fillStyle=f=dojox.gfx.makeParameters(dojox.gfx.defaultRadialGradient,_5);var _c=p.createFromXaml("<RadialGradientBrush/>"),c=dojox.gfx.matrix.multiplyPoint(dojox.gfx.matrix.invert(this._getAdjustedMatrix()),f.cx,f.cy),pt=c.x+","+c.y;_c.mappingMode="Absolute";_c.gradientOrigin=pt;_c.center=pt;_c.radiusX=_c.radiusY=f.r;dojo.forEach(f.colors,function(c){var t=p.createFromXaml("<GradientStop/>");t.offset=c.offset;t.color=dojox.gfx.silverlight.hexColor(c.color);_c.gradientStops.add(t);});this._setFillAttr(_c);break;case "pattern":this.fillStyle=null;this._setFillAttr(null);break;}return this;}this.fillStyle=f=dojox.gfx.normalizeColor(_5);var scb=p.createFromXaml("<SolidColorBrush/>");scb.color=f.toHex();scb.opacity=f.a;this._setFillAttr(scb);return this;},_setFillAttr:function(f){this.rawNode.fill=f;},setStroke:function(_13){var p=this.rawNode.getHost().content,r=this.rawNode;if(!_13){this.strokeStyle=null;r.stroke=null;return this;}if(typeof _13=="string"||dojo.isArray(_13)||_13 instanceof dojo.Color){_13={color:_13};}var s=this.strokeStyle=dojox.gfx.makeParameters(dojox.gfx.defaultStroke,_13);s.color=dojox.gfx.normalizeColor(s.color);if(s){var scb=p.createFromXaml("<SolidColorBrush/>");scb.color=s.color.toHex();scb.opacity=s.color.a;r.stroke=scb;r.strokeThickness=s.width;r.strokeStartLineCap=r.strokeEndLineCap=r.strokeDashCap=dojox.gfx.silverlight.caps[s.cap];if(typeof s.join=="number"){r.strokeLineJoin="Miter";r.strokeMiterLimit=s.join;}else{r.strokeLineJoin=dojox.gfx.silverlight.joins[s.join];}var da=s.style.toLowerCase();if(da in dojox.gfx.silverlight.dasharray){da=dojox.gfx.silverlight.dasharray[da];}if(da instanceof Array){da=dojo.clone(da);if(s.cap!="butt"){for(var i=0;i<da.length;i+=2){--da[i];if(da[i]<1){da[i]=1;}}for(var i=1;i<da.length;i+=2){++da[i];}}r.strokeDashArray=da.join(",");}else{r.strokeDashArray=null;}}return this;},_getParentSurface:function(){var _1a=this.parent;for(;_1a&&!(_1a instanceof dojox.gfx.Surface);_1a=_1a.parent){}return _1a;},_applyTransform:function(){var tm=this._getAdjustedMatrix(),r=this.rawNode;if(tm){var p=this.rawNode.getHost().content,m=p.createFromXaml("<MatrixTransform/>"),mm=p.createFromXaml("<Matrix/>");mm.m11=tm.xx;mm.m21=tm.xy;mm.m12=tm.yx;mm.m22=tm.yy;mm.offsetX=tm.dx;mm.offsetY=tm.dy;m.matrix=mm;r.renderTransform=m;}else{r.renderTransform=null;}return this;},setRawNode:function(_20){_20.fill=null;_20.stroke=null;this.rawNode=_20;},_moveToFront:function(){var c=this.parent.rawNode.children,r=this.rawNode;c.remove(r);c.add(r);return this;},_moveToBack:function(){var c=this.parent.rawNode.children,r=this.rawNode;c.remove(r);c.insert(0,r);return this;},_getAdjustedMatrix:function(){return this.matrix;}});dojo.declare("dojox.gfx.Group",dojox.gfx.Shape,{constructor:function(){dojox.gfx.silverlight.Container._init.call(this);},setRawNode:function(_25){this.rawNode=_25;}});dojox.gfx.Group.nodeType="Canvas";dojo.declare("dojox.gfx.Rect",dojox.gfx.shape.Rect,{setShape:function(_26){this.shape=dojox.gfx.makeParameters(this.shape,_26);this.bbox=null;var r=this.rawNode,n=this.shape;r.width=n.width;r.height=n.height;r.radiusX=r.radiusY=n.r;return this._applyTransform();},_getAdjustedMatrix:function(){var m=this.matrix,s=this.shape,d={dx:s.x,dy:s.y};return new dojox.gfx.Matrix2D(m?[m,d]:d);}});dojox.gfx.Rect.nodeType="Rectangle";dojo.declare("dojox.gfx.Ellipse",dojox.gfx.shape.Ellipse,{setShape:function(_2c){this.shape=dojox.gfx.makeParameters(this.shape,_2c);this.bbox=null;var r=this.rawNode,n=this.shape;r.width=2*n.rx;r.height=2*n.ry;return this._applyTransform();},_getAdjustedMatrix:function(){var m=this.matrix,s=this.shape,d={dx:s.cx-s.rx,dy:s.cy-s.ry};return new dojox.gfx.Matrix2D(m?[m,d]:d);}});dojox.gfx.Ellipse.nodeType="Ellipse";dojo.declare("dojox.gfx.Circle",dojox.gfx.shape.Circle,{setShape:function(_32){this.shape=dojox.gfx.makeParameters(this.shape,_32);this.bbox=null;var r=this.rawNode,n=this.shape;r.width=r.height=2*n.r;return this._applyTransform();},_getAdjustedMatrix:function(){var m=this.matrix,s=this.shape,d={dx:s.cx-s.r,dy:s.cy-s.r};return new dojox.gfx.Matrix2D(m?[m,d]:d);}});dojox.gfx.Circle.nodeType="Ellipse";dojo.declare("dojox.gfx.Line",dojox.gfx.shape.Line,{setShape:function(_38){this.shape=dojox.gfx.makeParameters(this.shape,_38);this.bbox=null;var r=this.rawNode,n=this.shape;r.x1=n.x1;r.y1=n.y1;r.x2=n.x2;r.y2=n.y2;return this;}});dojox.gfx.Line.nodeType="Line";dojo.declare("dojox.gfx.Polyline",dojox.gfx.shape.Polyline,{setShape:function(_3b,_3c){if(_3b&&_3b instanceof Array){this.shape=dojox.gfx.makeParameters(this.shape,{points:_3b});if(_3c&&this.shape.points.length){this.shape.points.push(this.shape.points[0]);}}else{this.shape=dojox.gfx.makeParameters(this.shape,_3b);}this.box=null;var p=this.shape.points,rp=[];for(var i=0;i<p.length;++i){if(typeof p[i]=="number"){rp.push(p[i],p[++i]);}else{rp.push(p[i].x,p[i].y);}}this.rawNode.points=rp.join(",");return this;}});dojox.gfx.Polyline.nodeType="Polyline";dojo.declare("dojox.gfx.Image",dojox.gfx.shape.Image,{setShape:function(_40){this.shape=dojox.gfx.makeParameters(this.shape,_40);this.bbox=null;var r=this.rawNode,n=this.shape;r.width=n.width;r.height=n.height;r.source=n.src;return this._applyTransform();},_getAdjustedMatrix:function(){var m=this.matrix,s=this.shape,d={dx:s.x,dy:s.y};return new dojox.gfx.Matrix2D(m?[m,d]:d);},setRawNode:function(_46){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -