This commit is contained in:
lzp
2026-03-13 11:18:36 +08:00
parent c2e26f0328
commit 3b320d0867
12 changed files with 180 additions and 50 deletions

View File

@@ -33,28 +33,27 @@ export class RectToolManager {
}
mouseMoveEvent(e) {
if (!this.isDragging) return;
const width = e.absolutePointer.x - this.startX
const height = e.absolutePointer.y - this.startY
this.demoObject.set({ width, height })
var width = e.absolutePointer.x - this.startX
var height = e.absolutePointer.y - this.startY
var left = this.startX
var top = this.startY
if (width < 0) {
left += width
width = -width
}
if (height < 0) {
top += height
height = -height
}
this.demoObject.set({ width, height, left, top })
this.canvasManager.canvas.renderAll()
}
mouseUpEvent(e) {
if (!this.isDragging) return;
this.isDragging = false;
var width = e.absolutePointer.x - this.startX
var height = e.absolutePointer.y - this.startY
if(width === 0) width = 50
if(height === 0) height = 50
this.demoObject.set({ width, height })
const object = this.demoObject.toJSON("evented")
if(object.width < 0) {
object.left += object.width
object.width = -object.width
}
if(object.height < 0) {
object.top += object.height
object.height = -object.height
}
if (object.width === 0) object.width = 100
if (object.height === 0) object.height = 100
this.layerManager.createRectLayer(object, true)
this.canvasManager.canvas.remove(this.demoObject)
this.canvasManager.canvas.renderAll()