New property fillAfterStrokeEnabled for Konva.Shape

This commit is contained in:
Anton Lavrenov
2020-11-22 13:49:15 -05:00
parent 98913337b4
commit f50019f176
9 changed files with 113 additions and 13 deletions

View File

@@ -521,6 +521,34 @@ suite('Shape', function () {
);
});
// ======================================================
test('draw fill after stroke', function () {
var stage = addStage();
var layer = new Konva.Layer();
var rect = new Konva.Rect({
x: 100,
y: 50,
width: 100,
height: 50,
fill: 'green',
stroke: 'red',
strokeWidth: 10,
fillAfterStrokeEnabled: true,
});
layer.add(rect);
stage.add(layer);
var trace = layer.getContext().getTrace();
assert.equal(
trace,
'clearRect(0,0,578,200);save();transform(1,0,0,1,100,50);beginPath();rect(0,0,100,50);closePath();lineWidth=10;strokeStyle=red;stroke();fillStyle=green;fill();restore();'
);
});
// ======================================================
test('test strokeWidth = 0', function () {
var stage = addStage();

View File

@@ -158,17 +158,17 @@ suite('RegularPolygon', function () {
stage.add(layer);
assert.deepEqual(poly.getSelfRect(), {
x: -50,
x: -47.55282581475768,
y: -50,
height: 100,
width: 100,
height: 90.45084971874738,
width: 95.10565162951536,
});
cloneAndCompareLayer(layer, 254);
Konva.pixelRatio = undefined;
});
test.only('triangle - bounding box', function () {
test('triangle - bounding box', function () {
var stage = addStage();
var layer = new Konva.Layer();