深度画布

This commit is contained in:
lzp
2026-03-20 13:23:00 +08:00
parent 34be403032
commit e00fe21e95
9 changed files with 378 additions and 5 deletions

View File

@@ -151,6 +151,37 @@ export class LayerManager {
if (isActive) this.setActiveID(emptyObject.info.id, false)
return emptyObject
}
/** 创建组图层 */
createGroupLayer(options?: any, isRecord = true, isActive = false) {
const child = options?.child || []
delete options.child
const groupObject = new fabric.Group(child, {
subTargetCheck: true, // 关键:检测子对象
interactive: true, // 启用交互
hasControls: true,
hasBorders: true,
// // 子对象样式
// cornerColor: 'blue',
// cornerSize: 8,
// borderColor: 'green',
// // 允许子对象独立变换
// lockScalingX: false,
// lockScalingY: false,
// lockRotation: false,
info: {
id: createId("group"),
name: '组图层',
...(options?.info || {}),
}
})
// this.setLayerPosition(groupObject)
this.canvasManager.add(groupObject, isRecord)
if (isActive) this.setActiveID(groupObject.info.id, false)
return groupObject
}
/** 创建文本图层 */
async createTextLayer(text: string, options?: any) {
const textObject = new fabric.IText(text, {