mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-18 10:31:08 +00:00
Update parser.js
Allow first example of stroke svg import to work properly
This commit is contained in:
parent
e524c13521
commit
f8e6ae9461
4 changed files with 21 additions and 29 deletions
|
|
@ -65,7 +65,7 @@
|
|||
}
|
||||
else if (attr === 'strokeDashArray') {
|
||||
value = value.replace(/,/g, ' ').split(/\s+/).map(function(n) {
|
||||
return parseInt(n);
|
||||
return parseFloat(n);
|
||||
});
|
||||
}
|
||||
else if (attr === 'transformMatrix') {
|
||||
|
|
|
|||
|
|
@ -971,16 +971,16 @@
|
|||
|
||||
//setup fill rule for current object
|
||||
this._setupCompositeOperation(ctx);
|
||||
|
||||
this._transform(ctx, noTransform);
|
||||
if (!noTransform) {
|
||||
this.transform(ctx);
|
||||
}
|
||||
this._setStrokeStyles(ctx);
|
||||
this._setFillStyles(ctx);
|
||||
|
||||
if (this.group && this.group.type === 'path-group') {
|
||||
ctx.translate(-this.group.width/2, -this.group.height/2);
|
||||
if (this.transformMatrix) {
|
||||
ctx.transform.apply(ctx, this.transformMatrix);
|
||||
}
|
||||
}
|
||||
if (this.transformMatrix) {
|
||||
ctx.transform.apply(ctx, this.transformMatrix);
|
||||
}
|
||||
this._setOpacity(ctx);
|
||||
this._setShadow(ctx);
|
||||
|
|
@ -993,17 +993,6 @@
|
|||
ctx.restore();
|
||||
},
|
||||
|
||||
_transform: function(ctx, noTransform) {
|
||||
var m = this.transformMatrix;
|
||||
|
||||
if (m && !this.group) {
|
||||
ctx.setTransform.apply(ctx, m);
|
||||
}
|
||||
if (!noTransform) {
|
||||
this.transform(ctx);
|
||||
}
|
||||
},
|
||||
|
||||
/* @private
|
||||
* @param {CanvasRenderingContext2D} ctx Context to render on
|
||||
*/
|
||||
|
|
@ -1137,7 +1126,6 @@
|
|||
if (1 & this.strokeDashArray.length) {
|
||||
this.strokeDashArray.push.apply(this.strokeDashArray, this.strokeDashArray);
|
||||
}
|
||||
|
||||
if (supportsLineDash) {
|
||||
ctx.setLineDash(this.strokeDashArray);
|
||||
this._stroke && this._stroke(ctx);
|
||||
|
|
|
|||
|
|
@ -420,29 +420,32 @@
|
|||
*/
|
||||
render: function(ctx, noTransform) {
|
||||
// do not render if width/height are zeros or object is not visible
|
||||
if (this.width === 0 || this.height === 0 || !this.visible) {
|
||||
if (!this.visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.save();
|
||||
|
||||
this._setupCompositeOperation(ctx);
|
||||
if (!noTransform) {
|
||||
this.transform(ctx);
|
||||
}
|
||||
this._setStrokeStyles(ctx);
|
||||
this._setFillStyles(ctx);
|
||||
if (this.group && this.group.type === 'path-group') {
|
||||
ctx.translate(-this.group.width/2, -this.group.height/2);
|
||||
ctx.translate(-this.group.width / 2, -this.group.height / 2);
|
||||
}
|
||||
if (this.transformMatrix) {
|
||||
ctx.transform.apply(ctx, this.transformMatrix);
|
||||
}
|
||||
this._setStrokeStyles(ctx);
|
||||
this._setFillStyles(ctx);
|
||||
this._setOpacity(ctx);
|
||||
this._setShadow(ctx);
|
||||
this.clipTo && fabric.util.clipContext(this, ctx);
|
||||
ctx.globalAlpha = this.group ? (ctx.globalAlpha * this.opacity) : this.opacity;
|
||||
this._render(ctx, noTransform);
|
||||
this.clipTo && ctx.restore();
|
||||
this._removeShadow(ctx);
|
||||
this._restoreCompositeOperation(ctx);
|
||||
|
||||
ctx.restore();
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -771,16 +771,17 @@
|
|||
}
|
||||
|
||||
ctx.save();
|
||||
this._transform(ctx, noTransform);
|
||||
if (!noTransform) {
|
||||
this.transform(ctx);
|
||||
}
|
||||
|
||||
var m = this.transformMatrix,
|
||||
isInPathGroup = this.group && this.group.type === 'path-group';
|
||||
var isInPathGroup = this.group && this.group.type === 'path-group';
|
||||
|
||||
if (isInPathGroup) {
|
||||
ctx.translate(-this.group.width/2, -this.group.height/2);
|
||||
}
|
||||
if (m) {
|
||||
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
||||
if (this.transformMatrix) {
|
||||
ctx.transform.apply(ctx, this.transformMatrix);
|
||||
}
|
||||
if (isInPathGroup) {
|
||||
ctx.translate(this.left, this.top);
|
||||
|
|
|
|||
Loading…
Reference in a new issue