Support fill on open paths

This commit is contained in:
Joaquín Cuenca Abela 2016-05-13 18:56:22 +02:00
parent 63de329144
commit c61df7ed65
2 changed files with 7 additions and 11 deletions

View File

@ -85,12 +85,7 @@
}
}
if (closedPath) {
context.fillStrokeShape(this);
}
else {
context.strokeShape(this);
}
context.fillStrokeShape(this);
},
getSelfRect: function() {
var points = [];

View File

@ -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() {