特殊形状更改宽高重新计算内部内容

This commit is contained in:
lzp
2026-04-01 16:03:20 +08:00
parent 883ca6b5cb
commit e23de30885
4 changed files with 27 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import { fabric } from 'fabric-with-all'
import { createId } from '../../tools/tools'
import { exportObjectsToImage, exportObjectToThumbnail } from '../tools/exportMethod'
import { OperationType } from '../tools/layerHelper'
import { getArrowPath, getLinePath, cloneObjects, getStarArr } from '../tools/canvasMethod'
export const FillSourceToBase64 = (source) => {
if (source?.toDataURL) {
@@ -215,6 +216,21 @@ export class ObjectManager {
async updateProperty(id: string, options: any, isRecord: boolean) {
const object = this.canvasManager.getObjectById(id)
if (!object) return null
const type = object.type
const isWidth = object.hasOwnProperty('width')
const isHeight = object.hasOwnProperty('height')
if (isWidth || isHeight) {
let width = options.width
let height = options.height
if (type === "polygon") {
if (object.points.length === 10) {// 五角星
options.points = getStarArr(width, height)
}
} else if (type === "ellipse") {// 椭圆
options.rx = width / 2
options.ry = height / 2
}
}
object.set(options);
this.canvasManager.renderAll()
if (isRecord) {