深度画布 矩形工具

This commit is contained in:
lzp
2026-03-12 15:51:18 +08:00
parent 86f1efbf43
commit d115047563
9 changed files with 378 additions and 213 deletions

View File

@@ -2,6 +2,7 @@ import { ref } from 'vue'
import { fabric } from 'fabric-with-all'
import { createId } from '../../tools/tools'
import { exportObjectsToImage } from '../tools/exportMethod'
import { OperationType } from '../tools/layerHelper'
export class LayerManager {
stateManager: any
@@ -18,6 +19,7 @@ export class LayerManager {
this.activeID.value = id
if (isActive) {
this.canvasManager.setActiveObjectByID(id)
this.stateManager.toolManager.setTool(OperationType.SELECT)
}
}
getLayerByID(id) {
@@ -114,7 +116,7 @@ export class LayerManager {
return textLayer
}
/** 创建矩形图层 */
createRectLayer(options?: any) {
createRectLayer(options?: any, isActive = false) {
const rectLayer = new fabric.Rect({
width: 100,
height: 100,
@@ -128,10 +130,11 @@ export class LayerManager {
})
this.setLayerPosition(rectLayer, options)
this.canvasManager.add(rectLayer)
if (isActive) this.setActiveID(rectLayer.info.id)
return rectLayer
}
/** 创建圆形图层 */
createCircleLayer(options?: any) {
createCircleLayer(options?: any, isActive = false) {
const circleLayer = new fabric.Circle({
radius: 50,
fill: '#000',
@@ -144,6 +147,7 @@ export class LayerManager {
})
this.setLayerPosition(circleLayer, options)
this.canvasManager.add(circleLayer)
if (isActive) this.setActiveID(circleLayer.info.id)
return circleLayer
}
/** 创建图片图层 */
@@ -215,5 +219,5 @@ export class LayerManager {
})
})
}
dispose() {}
dispose() { }
}