From c61df7ed65d487ab3fb2e27654509a646055d8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Cuenca=20Abela?= Date: Fri, 13 May 2016 18:56:22 +0200 Subject: [PATCH] Support fill on open paths --- src/shapes/Path.js | 7 +------ test/unit/shapes/Path-test.js | 11 ++++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/shapes/Path.js b/src/shapes/Path.js index 3d347ab7..15291385 100644 --- a/src/shapes/Path.js +++ b/src/shapes/Path.js @@ -85,12 +85,7 @@ } } - if (closedPath) { - context.fillStrokeShape(this); - } - else { - context.strokeShape(this); - } + context.fillStrokeShape(this); }, getSelfRect: function() { var points = []; diff --git a/test/unit/shapes/Path-test.js b/test/unit/shapes/Path-test.js index 5f21038a..d70ca323 100644 --- a/test/unit/shapes/Path-test.js +++ b/test/unit/shapes/Path-test.js @@ -827,16 +827,17 @@ suite('Path', function() { }); // ====================================================== - test('Stroke only when no fill', function() { + test('Stroke and fill when no closed', function() { - // https://github.com/ericdrowell/KonvaJS/issues/567 + // https://github.com/konvajs/konva/issues/150 var stage = addStage(); var layer = new Konva.Layer(); var path = new Konva.Path({ data: "M 50 0 C 50 150 170 170 200 170", - stroke: 'black' + stroke: 'black', + fill: '#ff0000' }); // override color key so that we can test the context trace @@ -865,8 +866,8 @@ suite('Path', function() { var hitTrace = layer.hitCanvas.getContext().getTrace(); //console.log(hitTrace); - assert.equal(trace, 'clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);beginPath();moveTo(50,0);bezierCurveTo(50,150,170,170,200,170);lineWidth=2;strokeStyle=black;stroke();restore();'); - assert.equal(hitTrace, 'clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);beginPath();moveTo(50,0);bezierCurveTo(50,150,170,170,200,170);lineWidth=2;strokeStyle=black;stroke();restore();'); + assert.equal(trace, 'clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);beginPath();moveTo(50,0);bezierCurveTo(50,150,170,170,200,170);fillStyle=#ff0000;fill();lineWidth=2;strokeStyle=black;stroke();restore();'); + assert.equal(hitTrace, 'clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);beginPath();moveTo(50,0);bezierCurveTo(50,150,170,170,200,170);save();fillStyle=black;fill();restore();lineWidth=2;strokeStyle=black;stroke();restore();'); }); it('getClientRect', function() {