Fix SVG rendering of lines and images in groups.

This commit is contained in:
kangax 2012-09-06 16:41:31 -04:00
parent ada83ffff5
commit 0171b665be
5 changed files with 15 additions and 1 deletions

7
dist/all.js vendored
View file

@ -9258,6 +9258,10 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
_render: function(ctx) {
ctx.beginPath();
if (this.group) {
ctx.translate(-this.group.width/2 + this.left, -this.group.height / 2 + this.top);
}
// move from center (of virtual box) to its left/top corner
ctx.moveTo(this.width === 1 ? 0 : (-this.width / 2), this.height === 1 ? 0 : (-this.height / 2));
ctx.lineTo(this.width === 1 ? 0 : (this.width / 2), this.height === 1 ? 0 : (this.height / 2));
@ -11958,6 +11962,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
ctx.save();
var m = this.transformMatrix;
this._resetWidthHeight();
if (this.group) {
ctx.translate(-this.group.width/2 + this.width/2, -this.group.height/2 + this.height/2);
}
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}

2
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -133,6 +133,9 @@
ctx.save();
var m = this.transformMatrix;
this._resetWidthHeight();
if (this.group) {
ctx.translate(-this.group.width/2 + this.width/2, -this.group.height/2 + this.height/2);
}
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}

View file

@ -83,6 +83,10 @@
_render: function(ctx) {
ctx.beginPath();
if (this.group) {
ctx.translate(-this.group.width/2 + this.left, -this.group.height / 2 + this.top);
}
// move from center (of virtual box) to its left/top corner
ctx.moveTo(this.width === 1 ? 0 : (-this.width / 2), this.height === 1 ? 0 : (-this.height / 2));
ctx.lineTo(this.width === 1 ? 0 : (this.width / 2), this.height === 1 ? 0 : (this.height / 2));