add cornerRadius as array to label tag

This commit is contained in:
Raphael Papazikas
2020-09-06 13:08:50 +02:00
parent d43d2cb9ba
commit 22a4a53a8c
5 changed files with 109 additions and 57 deletions

View File

@@ -269,4 +269,33 @@ suite('Label', function () {
layer.draw();
assert.equal(tag.width(), text.width());
});
test("tag cornerRadius", function() {
var stage = addStage();
var layer = new Konva.Layer();
var tag = new Konva.Tag({
x: 50,
y: 50,
width: 100,
height: 100,
fill: 'black',
cornerRadius: [0, 10, 20, 30],
});
layer.add(tag);
stage.add(layer);
layer.draw();
assert.equal(tag.cornerRadius()[0], 0);
assert.equal(tag.cornerRadius()[1], 10);
assert.equal(tag.cornerRadius()[2], 20);
assert.equal(tag.cornerRadius()[3], 30);
var trace = layer.getContext().getTrace();
assert.equal(
trace,
'clearRect(0,0,578,200);save();transform(1,0,0,1,50,50);beginPath();moveTo(0,0);lineTo(90,0);arc(90,10,10,4.712,0,false);lineTo(100,80);arc(80,80,20,0,1.571,false);lineTo(30,100);arc(30,70,30,1.571,3.142,false);lineTo(0,0);arc(0,0,0,3.142,4.712,false);closePath();fillStyle=black;fill();restore();clearRect(0,0,578,200);save();transform(1,0,0,1,50,50);beginPath();moveTo(0,0);lineTo(90,0);arc(90,10,10,4.712,0,false);lineTo(100,80);arc(80,80,20,0,1.571,false);lineTo(30,100);arc(30,70,30,1.571,3.142,false);lineTo(0,0);arc(0,0,0,3.142,4.712,false);closePath();fillStyle=black;fill();restore();'
);
});
});