深度画布缩略图

This commit is contained in:
lzp
2026-03-13 14:08:40 +08:00
parent 0a472bb590
commit 3db72ceefb
6 changed files with 73 additions and 62 deletions

View File

@@ -11,6 +11,7 @@ export async function cloneObjects(objects = []) {
height: obj.height,
scaleX: obj.scaleX,
scaleY: obj.scaleY,
angle: obj.angle,
})
resolve(v)
})
@@ -26,10 +27,11 @@ export async function getObjectsBoundingBox(objects = []) {
const box1 = { x: Infinity, y: Infinity }
const box2 = { x: -Infinity, y: -Infinity }
objects.forEach(obj => {
box1.x = Math.min(box1.x, obj.left)
box1.y = Math.min(box1.y, obj.top)
box2.x = Math.max(box2.x, obj.left + obj.width * obj.scaleX)
box2.y = Math.max(box2.y, obj.top + obj.height * obj.scaleY)
const rect = obj.getBoundingRect()
box1.x = Math.min(box1.x, rect.left)
box1.y = Math.min(box1.y, rect.top)
box2.x = Math.max(box2.x, rect.left + rect.width)
box2.y = Math.max(box2.y, rect.top + rect.height)
})
return {
left: box1.x,