// Note: fill alpha applies to all non-stroking operations
this.fillAlpha = 1;
this.strokeAlpha = 1;
+ this.lineWidth = 1;
this.old = old;
}
// Graphics state
setLineWidth: function canvasGraphicsSetLineWidth(width) {
+ this.current.lineWidth = width;
this.ctx.lineWidth = width;
},
setLineCap: function canvasGraphicsSetLineCap(style) {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx;
var strokeColor = this.current.strokeColor;
+ if (this.current.lineWidth === 0)
+ ctx.lineWidth = this.getSinglePixelWidth();
// For stroke we want to temporarily change the global alpha to the
// stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha;
ctx.translate(current.x, current.y);
ctx.scale(textHScale, 1);
- ctx.lineWidth /= current.textMatrix[0];
if (textSelection) {
this.save();
} else {
ctx.save();
this.applyTextTransforms();
- ctx.lineWidth /= current.textMatrix[0] * fontMatrix[0];
+
+ var lineWidth = current.lineWidth;
+ var scale = Math.abs(current.textMatrix[0] * fontMatrix[0]);
+ if (scale == 0 || lineWidth == 0)
+ lineWidth = this.getSinglePixelWidth();
+ else
+ lineWidth /= scale;
+
+ ctx.lineWidth = lineWidth;
if (textSelection)
text.geom = this.getTextGeometry();
},
restoreFillRule: function canvasGraphicsRestoreFillRule(rule) {
this.ctx.mozFillRule = rule;
+ },
+ getSinglePixelWidth: function getSinglePixelWidth(scale) {
+ var inverse = this.ctx.mozCurrentTransformInverse;
+ return Math.abs(inverse[0] + inverse[2]);
}
};