📄 matrix.js
字号:
}, multiplyPoint: function(matrix, /* Number||Point */ a, /* Number, optional */ b){ // summary: applies a matrix to a point // matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix object to be applied // a: Number: an x coordinate of a point // b: Number: a y coordinate of a point var M = m.normalize(matrix); if(typeof a == "number" && typeof b == "number"){ return m._multiplyPoint(M, a, b); // dojox.gfx.Point } // branch // matrix: dojox.gfx.matrix.Matrix2D: a 2D matrix object to be applied // a: dojox.gfx.Point: a point // b: null return m._multiplyPoint(M, a.x, a.y); // dojox.gfx.Point }, multiply: function(matrix){ // summary: combines matrices by multiplying them sequentially in the given order // matrix: dojox.gfx.matrix.Matrix2D...: a 2D matrix-like object, // all subsequent arguments are matrix-like objects too var M = m.normalize(matrix); // combine matrices for(var i = 1; i < arguments.length; ++i){ var l = M, r = m.normalize(arguments[i]); M = new m.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; // dojox.gfx.matrix.Matrix2D }, // high level operations _sandwich: function(matrix, x, y){ // summary: applies a matrix at a centrtal point // matrix: dojox.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 m.multiply(m.translate(x, y), matrix, m.translate(-x, -y)); // dojox.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 dojox.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 m._sandwich(m.scale(a, b), c, d); // dojox.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 m._sandwich(m.scale(a), b, c); // dojox.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: dojox.gfx.Point: a central point // d: null return m._sandwich(m.scale(a, b), c.x, c.y); // dojox.gfx.matrix.Matrix2D } // branch // a: Number: a uniform scaling factor used for both coordinates // b: dojox.gfx.Point: a central point // c: null // d: null return m._sandwich(m.scale(a), b.x, b.y); // dojox.gfx.matrix.Matrix2D }, rotateAt: function(angle, a, b){ // summary: rotates a picture using a specified point as a center of rotation // description: Compare with dojox.gfx.matrix.rotate(). // angle: Number: an angle of rotation in radians (>0 for CW) // 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 m._sandwich(m.rotate(angle), a, b); // dojox.gfx.matrix.Matrix2D } // branch // angle: Number: an angle of rotation in radians (>0 for CCW) // a: dojox.gfx.Point: a central point // b: null return m._sandwich(m.rotate(angle), a.x, a.y); // dojox.gfx.matrix.Matrix2D }, rotategAt: function(degree, a, b){ // summary: rotates a picture using a specified point as a center of rotation // description: Compare with dojox.gfx.matrix.rotateg(). // degree: Number: an angle of rotation in degrees (>0 for CW) // 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 m._sandwich(m.rotateg(degree), a, b); // dojox.gfx.matrix.Matrix2D } // branch // degree: Number: an angle of rotation in degrees (>0 for CCW) // a: dojox.gfx.Point: a central point // b: null return m._sandwich(m.rotateg(degree), a.x, a.y); // dojox.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 dojox.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 m._sandwich(m.skewX(angle), a, b); // dojox.gfx.matrix.Matrix2D } // branch // angle: Number: an skewing angle in radians // a: dojox.gfx.Point: a central point // b: null return m._sandwich(m.skewX(angle), a.x, a.y); // dojox.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 dojox.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 m._sandwich(m.skewXg(degree), a, b); // dojox.gfx.matrix.Matrix2D } // branch // degree: Number: an skewing angle in degrees // a: dojox.gfx.Point: a central point // b: null return m._sandwich(m.skewXg(degree), a.x, a.y); // dojox.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 dojox.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 m._sandwich(m.skewY(angle), a, b); // dojox.gfx.matrix.Matrix2D } // branch // angle: Number: an skewing angle in radians // a: dojox.gfx.Point: a central point // b: null return m._sandwich(m.skewY(angle), a.x, a.y); // dojox.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 dojox.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 m._sandwich(m.skewYg(degree), a, b); // dojox.gfx.matrix.Matrix2D } // branch // degree: Number: an skewing angle in degrees // a: dojox.gfx.Point: a central point // b: null return m._sandwich(m.skewYg(degree), a.x, a.y); // dojox.gfx.matrix.Matrix2D } //TODO: rect-to-rect mapping, scale-to-fit (isotropic and anisotropic versions) });})();// propagate Matrix2D updojox.gfx.Matrix2D = dojox.gfx.matrix.Matrix2D;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -