?? matrix.js
字號:
return dojo.gfx.matrix._multiplyPoint(m, a.x, a.y); // dojo.gfx.Point }, multiply: function(matrix){ // summary: combines matrices by multiplying them sequentially in the given order // matrix: dojo.gfx.matrix.Matrix2D...: a 2D matrix-like object, // all subsequent arguments are matrix-like objects too var m = dojo.gfx.matrix.normalize(matrix); // combine matrices for(var i = 1; i < arguments.length; ++i){ var l = m; var r = dojo.gfx.matrix.normalize(arguments[i]); m = new dojo.gfx.matrix.Matrix2D(); m.xx = l.xx * r.xx + l.xy * r.yx; m.xy = l.xx * r.xy + l.xy * r.yy; m.yx = l.yx * r.xx + l.yy * r.yx; m.yy = l.yx * r.xy + l.yy * r.yy; m.dx = l.xx * r.dx + l.xy * r.dy + l.dx; m.dy = l.yx * r.dx + l.yy * r.dy + l.dy; } return m; // dojo.gfx.matrix.Matrix2D }, // high level operations _sandwich: function(m, x, y){ // summary: applies a matrix at a centrtal point // m: dojo.gfx.matrix.Matrix2D: a 2D matrix-like object, which is applied at a central point // x: Number: an x component of the central point // y: Number: a y component of the central point return dojo.gfx.matrix.multiply(dojo.gfx.matrix.translate(x, y), m, dojo.gfx.matrix.translate(-x, -y)); // dojo.gfx.matrix.Matrix2D }, scaleAt: function(a, b, c, d){ // summary: scales a picture using a specified point as a center of scaling // description: Compare with dojo.gfx.matrix.scale(). // a: Number: a scaling factor used for the x coordinate // b: Number: a scaling factor used for the y coordinate // c: Number: an x component of a central point // d: Number: a y component of a central point // accepts several signatures: // 1) uniform scale factor, Point // 2) uniform scale factor, x, y // 3) x scale, y scale, Point // 4) x scale, y scale, x, y switch(arguments.length){ case 4: // a and b are scale factor components, c and d are components of a point return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.scale(a, b), c, d); // dojo.gfx.matrix.Matrix2D case 3: if(typeof c == "number"){ // branch // a: Number: a uniform scaling factor used for both coordinates // b: Number: an x component of a central point // c: Number: a y component of a central point // d: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.scale(a), b, c); // dojo.gfx.matrix.Matrix2D } // branch // a: Number: a scaling factor used for the x coordinate // b: Number: a scaling factor used for the y coordinate // c: dojo.gfx.Point: a central point // d: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.scale(a, b), c.x, c.y); // dojo.gfx.matrix.Matrix2D } // branch // a: Number: a uniform scaling factor used for both coordinates // b: dojo.gfx.Point: a central point // c: null // d: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.scale(a), b.x, b.y); // dojo.gfx.matrix.Matrix2D }, rotateAt: function(angle, a, b){ // summary: rotates a picture using a specified point as a center of rotation // description: Compare with dojo.gfx.matrix.rotate(). // angle: Number: an angle of rotation in radians (>0 for CCW) // a: Number: an x component of a central point // b: Number: a y component of a central point // accepts several signatures: // 1) rotation angle in radians, Point // 2) rotation angle in radians, x, y if(arguments.length > 2){ return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.rotate(angle), a, b); // dojo.gfx.matrix.Matrix2D } // branch // angle: Number: an angle of rotation in radians (>0 for CCW) // a: dojo.gfx.Point: a central point // b: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.rotate(angle), a.x, a.y); // dojo.gfx.matrix.Matrix2D }, rotategAt: function(degree, a, b){ // summary: rotates a picture using a specified point as a center of rotation // description: Compare with dojo.gfx.matrix.rotateg(). // degree: Number: an angle of rotation in degrees (>0 for CCW) // a: Number: an x component of a central point // b: Number: a y component of a central point // accepts several signatures: // 1) rotation angle in degrees, Point // 2) rotation angle in degrees, x, y if(arguments.length > 2){ return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.rotateg(degree), a, b); // dojo.gfx.matrix.Matrix2D } // branch // degree: Number: an angle of rotation in degrees (>0 for CCW) // a: dojo.gfx.Point: a central point // b: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.rotateg(degree), a.x, a.y); // dojo.gfx.matrix.Matrix2D }, skewXAt: function(angle, a, b){ // summary: skews a picture along the x axis using a specified point as a center of skewing // description: Compare with dojo.gfx.matrix.skewX(). // angle: Number: an skewing angle in radians // a: Number: an x component of a central point // b: Number: a y component of a central point // accepts several signatures: // 1) skew angle in radians, Point // 2) skew angle in radians, x, y if(arguments.length > 2){ return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewX(angle), a, b); // dojo.gfx.matrix.Matrix2D } // branch // angle: Number: an skewing angle in radians // a: dojo.gfx.Point: a central point // b: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewX(angle), a.x, a.y); // dojo.gfx.matrix.Matrix2D }, skewXgAt: function(degree, a, b){ // summary: skews a picture along the x axis using a specified point as a center of skewing // description: Compare with dojo.gfx.matrix.skewXg(). // degree: Number: an skewing angle in degrees // a: Number: an x component of a central point // b: Number: a y component of a central point // accepts several signatures: // 1) skew angle in degrees, Point // 2) skew angle in degrees, x, y if(arguments.length > 2){ return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewXg(degree), a, b); // dojo.gfx.matrix.Matrix2D } // branch // degree: Number: an skewing angle in degrees // a: dojo.gfx.Point: a central point // b: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewXg(degree), a.x, a.y); // dojo.gfx.matrix.Matrix2D }, skewYAt: function(angle, a, b){ // summary: skews a picture along the y axis using a specified point as a center of skewing // description: Compare with dojo.gfx.matrix.skewY(). // angle: Number: an skewing angle in radians // a: Number: an x component of a central point // b: Number: a y component of a central point // accepts several signatures: // 1) skew angle in radians, Point // 2) skew angle in radians, x, y if(arguments.length > 2){ return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewY(angle), a, b); // dojo.gfx.matrix.Matrix2D } // branch // angle: Number: an skewing angle in radians // a: dojo.gfx.Point: a central point // b: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewY(angle), a.x, a.y); // dojo.gfx.matrix.Matrix2D }, skewYgAt: function(/* Number */ degree, /* Number||Point */ a, /* Number, optional */ b){ // summary: skews a picture along the y axis using a specified point as a center of skewing // description: Compare with dojo.gfx.matrix.skewYg(). // degree: Number: an skewing angle in degrees // a: Number: an x component of a central point // b: Number: a y component of a central point // accepts several signatures: // 1) skew angle in degrees, Point // 2) skew angle in degrees, x, y if(arguments.length > 2){ return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewYg(degree), a, b); // dojo.gfx.matrix.Matrix2D } // branch // degree: Number: an skewing angle in degrees // a: dojo.gfx.Point: a central point // b: null return dojo.gfx.matrix._sandwich(dojo.gfx.matrix.skewYg(degree), a.x, a.y); // dojo.gfx.matrix.Matrix2D } // TODO: rect-to-rect mapping, scale-to-fit (isotropic and anisotropic versions) });
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -