深度画布调整属性设置

This commit is contained in:
lzp
2026-03-26 10:53:01 +08:00
parent e03bb2486c
commit 164ac3789f
10 changed files with 259 additions and 177 deletions

View File

@@ -1,5 +1,5 @@
import { OperationType, OperationTypes } from "../tools/layerHelper";
import { getStarArr, getArrowPath, distance, angleBetweenPointsDegrees } from "../tools/canvasMethod";
import { getStarArr, getArrowPath, getLinePath, distance, angleBetweenPointsDegrees } from "../tools/canvasMethod";
import { fabric } from 'fabric-with-all'
/** 形状管理器 */
export class ShapeToolManager {
@@ -136,22 +136,47 @@ export class ShapeToolManager {
/** 绘制直线 */
downLine() {
const line = new fabric.Line([this.startX, this.startY, this.startX, this.startY], {
stroke: 'black', // 线条颜色
strokeWidth: 2 // 线条粗细
})
return line
// const line = new fabric.Line([this.startX, this.startY, this.startX, this.startY], {
// stroke: 'black', // 线条颜色
// strokeWidth: 2 // 线条粗细
// })
// return line
return new fabric.Path();
}
moveLine({ x, y }) {
this.demoObject.set({
x1: this.startX,
y1: this.startY,
x2: x,
y2: y,
})
// this.demoObject.set({
// x1: this.startX,
// y1: this.startY,
// x2: x,
// y2: y,
// })
const width = distance(this.startX, this.startY, x, y)
const angle = angleBetweenPointsDegrees(this.startX, this.startY, x, y)
this.canvasManager.canvas.remove(this.demoObject)
const arrow = new fabric.Path(getLinePath(width, 2), {
left: this.startX,
top: this.startY,
stroke: '#000', // 只设置边框颜色
strokeWidth: 2, // 边框宽度
fill: 'transparent', // 不填充
strokeLineCap: 'round',
strokeLineJoin: 'round',
originY: 'center',
angle: angle,
});
this.canvasManager.canvas.add(arrow)
this.demoObject = arrow
}
upLine(object) {
this.layerManager.createLineLayer(object)
if (object.originY !== "center") {
this.layerManager.createLineLayer({
left: this.startX,
top: this.startY,
})
} else {
this.layerManager.createLineLayer(object)
}
// this.layerManager.createLineLayer(object)
}
/** 绘制椭圆 */
@@ -228,11 +253,11 @@ export class ShapeToolManager {
const width = distance(this.startX, this.startY, x, y)
const angle = angleBetweenPointsDegrees(this.startX, this.startY, x, y)
this.canvasManager.canvas.remove(this.demoObject)
const arrow = new fabric.Path(getArrowPath(width, 10), {
const arrow = new fabric.Path(getArrowPath(width, 4), {
left: this.startX,
top: this.startY,
stroke: '#000', // 只设置边框颜色
strokeWidth: 3, // 边框宽度
strokeWidth: 4, // 边框宽度
fill: 'transparent', // 不填充
strokeLineCap: 'round',
strokeLineJoin: 'round',
@@ -247,7 +272,7 @@ export class ShapeToolManager {
this.layerManager.createArrowLayer({
left: this.startX,
top: this.startY,
}, true)
})
} else {
this.layerManager.createArrowLayer(object)
}