strokeWidth = 0 bug fix

This commit is contained in:
Anton Lavrenov 2019-02-25 07:55:36 -05:00
parent 35961a3a6d
commit 899d0942ea
5 changed files with 43 additions and 3 deletions

View File

@ -8,7 +8,7 @@
* Konva JavaScript Framework v3.0.0-3
* http://konvajs.org/
* Licensed under the MIT
* Date: Sun Feb 24 2019
* Date: Mon Feb 25 2019
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -6717,6 +6717,7 @@
*/
Shape.prototype.hasStroke = function () {
return (this.strokeEnabled() &&
this.strokeWidth() &&
!!(this.stroke() || this.strokeLinearGradientColorStops())
// this.getStrokeRadialGradientColorStops()
);

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -38,6 +38,7 @@
"gulp-util": "^3.0.8",
"mocha": "5.2.0",
"mocha-headless-chrome": "^2.0.2",
"parcel-bundler": "^1.11.0",
"prettier": "^1.16.4",
"typescript": "^3.3.1"
},

View File

@ -289,6 +289,7 @@ export class Shape extends Node {
hasStroke() {
return (
this.strokeEnabled() &&
this.strokeWidth() &&
!!(this.stroke() || this.strokeLinearGradientColorStops())
// this.getStrokeRadialGradientColorStops()
);

View File

@ -514,6 +514,43 @@ suite('Shape', function() {
);
});
// ======================================================
test('test strokeWidth = 0', function() {
var stage = addStage();
var layer = new Konva.Layer();
var rect = new Konva.Rect({
x: 100,
y: 50,
width: 100,
height: 50,
fill: 'green',
strokeWidth: 0,
stroke: 'black'
});
layer.add(rect);
stage.add(layer);
var canvas = createCanvas();
var context = canvas.getContext('2d');
context.beginPath();
context.rect(100, 50, 100, 50);
context.closePath();
context.fillStyle = 'green';
context.fill();
var trace = layer.getContext().getTrace();
compareLayerAndCanvas(layer, canvas, 30);
assert.equal(
trace,
'clearRect(0,0,578,200);save();transform(1,0,0,1,100,50);beginPath();rect(0,0,100,50);closePath();fillStyle=green;fill();restore();'
);
});
// ======================================================
test('stroke with shadow and opacity', function() {
Konva.pixelRatio = 1;