perf: 导出PPTX优化(阴影角度)

This commit is contained in:
pipipi-pikachu 2022-04-30 10:27:18 +08:00
parent 2b3ce493f0
commit 113a755e3a

View File

@ -255,13 +255,59 @@ export default () => {
// 获取阴影配置 // 获取阴影配置
const getShadowOption = (shadow: PPTElementShadow): pptxgen.ShadowProps => { const getShadowOption = (shadow: PPTElementShadow): pptxgen.ShadowProps => {
const c = formatColor(shadow.color) const c = formatColor(shadow.color)
const { h, v } = shadow
let offset = 4
let angle = 45
if (h === 0 && v === 0) {
offset = 4
angle = 45
}
else if (h === 0) {
if (v > 0) {
offset = v
angle = 90
}
else {
offset = -v
angle = 270
}
}
else if (v === 0) {
if (h > 0) {
offset = h
angle = 1
}
else {
offset = -h
angle = 180
}
}
else if (h > 0 && v > 0) {
offset = Math.max(h, v)
angle = 45
}
else if (h > 0 && v < 0) {
offset = Math.max(h, -v)
angle = 315
}
else if (h < 0 && v > 0) {
offset = Math.max(-h, v)
angle = 135
}
else if (h < 0 && v < 0) {
offset = Math.max(-h, -v)
angle = 225
}
return { return {
type: 'outer', type: 'outer',
color: c.color.replace('#', ''), color: c.color.replace('#', ''),
opacity: c.alpha, opacity: c.alpha,
blur: shadow.blur * 0.75, blur: shadow.blur * 0.75,
offset: (shadow.h + shadow.v) / 2 * 0.75, offset,
angle: 45, angle,
} }
} }