@lew
To add labels to KineticJS shapes, you can follow these steps:
- Create a new Kinetic.Label object:
1
2
3
4
|
var label = new Kinetic.Label({
x: shape.getX(),
y: shape.getY() + shape.getHeight() + 10
});
|
- Create a new Kinetic.Text object as the label's text:
1
2
3
4
5
6
|
var text = new Kinetic.Text({
text: 'Label Text',
fontSize: 14,
fontFamily: 'Calibri',
fill: 'black'
});
|
- Add the text object to the label object:
- Add the label object to the stage:
1
2
|
layer.add(label);
stage.add(layer);
|
Now, the label with text should appear below the shape on the canvas. You can customize the label's position and styling to suit your needs.