perf: 导出PPTX优化(矩形、圆形图片裁剪)

This commit is contained in:
pipipi-pikachu 2022-04-26 23:03:40 +08:00
parent 727bdb7bc5
commit 289b12cd11

View File

@ -321,7 +321,6 @@ export default () => {
if (el.flipH) options.flipH = el.flipH if (el.flipH) options.flipH = el.flipH
if (el.flipV) options.flipV = el.flipV if (el.flipV) options.flipV = el.flipV
if (el.rotate) options.rotate = el.rotate if (el.rotate) options.rotate = el.rotate
if (el.clip && el.clip.shape === 'ellipse') options.rounding = true
if (el.link) { if (el.link) {
const { type, target } = el.link const { type, target } = el.link
if (type === 'web') options.hyperlink = { url: target } if (type === 'web') options.hyperlink = { url: target }
@ -331,6 +330,22 @@ export default () => {
} }
} }
if (el.filters?.opacity) options.transparency = 100 - parseInt(el.filters?.opacity) if (el.filters?.opacity) options.transparency = 100 - parseInt(el.filters?.opacity)
if (el.clip) {
if (el.clip.shape === 'ellipse') options.rounding = true
const range = el.clip.range
const originW = el.width / ((range[1][0] - range[0][0]) / 100)
const originH = el.height / ((range[1][1] - range[0][1]) / 100)
options.w = originW / 100
options.h = originH / 100
const x = range[0][0] / 100 * originW / 100
const y = range[0][1] / 100 * originH / 100
const w = (range[1][0] - range[0][0]) / 100 * originW / 100
const h = (range[1][1] - range[0][1]) / 100 * originH / 100
options.sizing = { type: 'crop', w, h, x, y }
}
pptxSlide.addImage(options) pptxSlide.addImage(options)
} }