1. 动画
// 添加文本
let text = new fabric.FabricText('hello world', { left: 100, top: 100 })
canvas.add(text)
text.animate(
{
left: 300,
top: 200,
fontSize: 48,
fill: 'blue'
},
{
duration: 2000, // 设置动画的持续时间为 2000 毫秒
onChange: canvas.renderAll.bind(canvas), // 在动画过程中更新 canvas
easing: fabric.util.ease.easeInQuad,
onComplete: () => {
console.log(1111)
}
}
)
2. 事件
let fn = (opt) => {
console.log(opt)
}
text.on('mousedown', fn)
点击选中样式
// 选择框是否有边框
// circle.hasBorders = false
// 选择框是否有操作
// circle.hasControls = false
circle.set({
transparentCorners: false,
cornerColor: 'blue',
cornerStrokeColor: 'red',
borderColor: 'red',
cornerSize: 12,
padding: 10,
cornerStyle: 'circle',
borderDashArray: [3, 3]
})