我有一个带有一些矩形的项目,我需要在其中放入文本。是否有一个 Konva 类可以做到这一点?我曾尝试使用 Konva.group(),标签 ...
这是我的最后一次尝试,一开始文本保持原样,但是在移动 Rect 时,位置没有更新。
var rect = new Konva.Rect({
x: 20,
y: 60,
stroke: '#123456',
strokeWidth: 5,
fill: '#ddd',
width: 600,
height: 450,
shadowColor: 'black',
shadowBlur: 10,
shadowOffset: [10, 10],
shadowOpacity: 0.2,
cornerRadius: 10,
draggable: true,
})
var complexText = new Konva.Text({
x: ((rect.attrs.width + rect.attrs.x) - 300)/2 ,
y: ((rect.attrs.height + rect.attrs.y))/2,
text:
"COMPLEX TEXT\n\nAll the world's a stage, and all the men and women merely players. They have their exits and their entrances.",
fontSize: …Run Code Online (Sandbox Code Playgroud)