Skip to content

Commit

Permalink
Fixed wrong viewBox in IE, matrix invert method, pathDimention caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBaranovskiy committed Apr 4, 2011
1 parent 88a59f8 commit 66450da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion raphael-min.js

Large diffs are not rendered by default.

41 changes: 30 additions & 11 deletions raphael.js
Expand Up @@ -1026,6 +1026,13 @@
width: mmax[apply](0, X) - xmin,
height: mmax[apply](0, Y) - ymin
};
}, null, function (o) {
return {
x: o.x,
y: o.y,
width: o.width,
height: o.height
};
}),
pathClone = function (pathArray) {
var res = [];
Expand Down Expand Up @@ -1716,12 +1723,12 @@
};
function Matrix(a, b, c, d, e, f) {
if (a != null) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.a = +a;
this.b = +b;
this.c = +c;
this.d = +d;
this.e = +e;
this.f = +f;
} else {
this.a = 1;
this.b = 0;
Expand Down Expand Up @@ -1759,8 +1766,9 @@
this.f = out[1][2];
};
matrixproto.invert = function () {
var x = a * d - b * c;
return new Matrix(d / x, -b / x, -c / x, a / x, (c * f - d * e) / x, (b * e - a * f) / x);
var me = this,
x = me.a * me.d - me.b * me.c;
return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x);
};
matrixproto.clone = function () {
return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);
Expand Down Expand Up @@ -2595,7 +2603,7 @@
\*/
elproto.transform = function (tstr) {
var _ = this._;
if (!tstr) {
if (tstr == null) {
return _.transform;
}
extractTransform(this, tstr);
Expand Down Expand Up @@ -3525,8 +3533,13 @@
}
extractTransform(this, tstr);
var matrix = this.matrix.clone(),
vbs = this.paper._viewBoxShift,
skew = this.skew;
matrix.translate(-.5, -.5);
if (vbs) {
matrix.scale(vbs.scale, vbs.scale, -1, -1);
matrix.add(1, 0, 0, 1, vbs.dx, vbs.dy);
}
if (this.type == "image") {
if (Str(tstr).indexOf("m") + 1) {
this.node.style.filter = matrix.toFilter();
Expand All @@ -3551,7 +3564,7 @@
// angle = fill.angle;

this.node.style.filter = E;
skew.matrix = matrix;
skew.matrix = Str(matrix);
skew.offset = matrix.offset();

// if (0&&angle) {
Expand Down Expand Up @@ -3922,7 +3935,7 @@
eve("setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var width = this.width,
height = this.height,
size = 1e3 * mmax(w / width, h / height),
size = 1 / mmax(w / width, h / height),
H, W;
if (fit) {
H = height / h;
Expand All @@ -3935,6 +3948,11 @@
}
}
this._viewBox = [x, y, w, h, !!fit];
this._viewBoxShift = {
dx: -x,
dy: -y,
scale: size
};
this.forEach(function (el) {
el.transform("...");
});
Expand Down Expand Up @@ -4612,6 +4630,7 @@
}
_.bbox = pathDimensions(mapPath(this.realPath, this.matrix));
_.bbox.toString = x_y_w_h;
console.log(mapPath(this.realPath, this.matrix)+"");
_.dirty = _.dirtyT = 0;
}
return _.bbox;
Expand Down

0 comments on commit 66450da

Please sign in to comment.