This commit is contained in:
MaxGraey 2018-03-21 20:31:16 +02:00
parent 7e1a6dbd1b
commit 2976c5bff9
3 changed files with 13 additions and 49 deletions

View File

@ -2083,22 +2083,16 @@
var pixelRatio = this.getCanvas().getPixelRatio(); var pixelRatio = this.getCanvas().getPixelRatio();
if (shape.hasStroke()) { if (shape.hasStroke()) {
/* if (!strokeScaleEnabled) {
this.save();
var pixelRatio = this.getCanvas().getPixelRatio();
var transform = this._context.currentTransform;
this.setTransform(pixelRatio, transform.b, transform.c, pixelRatio, transform.e, transform.f);
} */
this._applyLineCap(shape); this._applyLineCap(shape);
if (dash && shape.dashEnabled()) { if (dash && shape.dashEnabled()) {
if (!strokeScaleEnabled) { if (!strokeScaleEnabled) {
scale = pixelRatio / (this._context.currentTransform ? this._context.currentTransform.a : 1); scale = pixelRatio / (this._context.currentTransform ? this._context.currentTransform.a : 1);
var newDash = dash.slice(); var len = dash.length;
for (var i = 0, len = dash.length; i < len; i++) { var scaledDash = new Array(len);
newDash[i] *= scale; for (var i = 0; i < len; i++) {
scaledDash[i] = dash[i] * scale;
} }
this.setLineDash(newDash); this.setLineDash(scaledDash);
} else { } else {
this.setLineDash(dash); this.setLineDash(dash);
} }
@ -2126,10 +2120,6 @@
} }
shape._strokeFunc(this); shape._strokeFunc(this);
/* if (!strokeScaleEnabled) {
this.restore();
} */
} }
}, },
_applyShadow: function(shape) { _applyShadow: function(shape) {
@ -2179,12 +2169,7 @@
// ignore strokeScaleEnabled for Text // ignore strokeScaleEnabled for Text
var strokeScaleEnabled = var strokeScaleEnabled =
shape.getStrokeScaleEnabled() || shape instanceof Konva.Text; shape.getStrokeScaleEnabled() || shape instanceof Konva.Text;
/* if (!strokeScaleEnabled) {
this.save();
var pixelRatio = this.getCanvas().getPixelRatio();
var transform = this._context.currentTransform;
this.setTransform(pixelRatio, transform.b, transform.c, pixelRatio, transform.e, transform.f);
} */
this._applyLineCap(shape); this._applyLineCap(shape);
if (!strokeScaleEnabled) { if (!strokeScaleEnabled) {
var pixelRatio = this.getCanvas().getPixelRatio(); var pixelRatio = this.getCanvas().getPixelRatio();
@ -2195,9 +2180,6 @@
} }
this.setAttr('strokeStyle', shape.colorKey); this.setAttr('strokeStyle', shape.colorKey);
shape._strokeFuncHit(this); shape._strokeFuncHit(this);
/* if (!strokeScaleEnabled) {
this.restore();
} */
} }
} }
}; };

2
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -624,22 +624,16 @@
var pixelRatio = this.getCanvas().getPixelRatio(); var pixelRatio = this.getCanvas().getPixelRatio();
if (shape.hasStroke()) { if (shape.hasStroke()) {
/* if (!strokeScaleEnabled) {
this.save();
var pixelRatio = this.getCanvas().getPixelRatio();
var transform = this._context.currentTransform;
this.setTransform(pixelRatio, transform.b, transform.c, pixelRatio, transform.e, transform.f);
} */
this._applyLineCap(shape); this._applyLineCap(shape);
if (dash && shape.dashEnabled()) { if (dash && shape.dashEnabled()) {
if (!strokeScaleEnabled) { if (!strokeScaleEnabled) {
scale = pixelRatio / (this._context.currentTransform ? this._context.currentTransform.a : 1); scale = pixelRatio / (this._context.currentTransform ? this._context.currentTransform.a : 1);
var newDash = dash.slice(); var len = dash.length;
for (var i = 0, len = dash.length; i < len; i++) { var scaledDash = new Array(len);
newDash[i] *= scale; for (var i = 0; i < len; i++) {
scaledDash[i] = dash[i] * scale;
} }
this.setLineDash(newDash); this.setLineDash(scaledDash);
} else { } else {
this.setLineDash(dash); this.setLineDash(dash);
} }
@ -667,10 +661,6 @@
} }
shape._strokeFunc(this); shape._strokeFunc(this);
/* if (!strokeScaleEnabled) {
this.restore();
} */
} }
}, },
_applyShadow: function(shape) { _applyShadow: function(shape) {
@ -720,12 +710,7 @@
// ignore strokeScaleEnabled for Text // ignore strokeScaleEnabled for Text
var strokeScaleEnabled = var strokeScaleEnabled =
shape.getStrokeScaleEnabled() || shape instanceof Konva.Text; shape.getStrokeScaleEnabled() || shape instanceof Konva.Text;
/* if (!strokeScaleEnabled) {
this.save();
var pixelRatio = this.getCanvas().getPixelRatio();
var transform = this._context.currentTransform;
this.setTransform(pixelRatio, transform.b, transform.c, pixelRatio, transform.e, transform.f);
} */
this._applyLineCap(shape); this._applyLineCap(shape);
if (!strokeScaleEnabled) { if (!strokeScaleEnabled) {
var pixelRatio = this.getCanvas().getPixelRatio(); var pixelRatio = this.getCanvas().getPixelRatio();
@ -736,9 +721,6 @@
} }
this.setAttr('strokeStyle', shape.colorKey); this.setAttr('strokeStyle', shape.colorKey);
shape._strokeFuncHit(this); shape._strokeFuncHit(this);
/* if (!strokeScaleEnabled) {
this.restore();
} */
} }
} }
}; };