From 113a755e3a6a2180910dc3446ba1c231bc4ad11c Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sat, 30 Apr 2022 10:27:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AF=BC=E5=87=BAPPTX=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=88=E9=98=B4=E5=BD=B1=E8=A7=92=E5=BA=A6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useExport.ts | 50 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/hooks/useExport.ts b/src/hooks/useExport.ts index 5f98e155..4a84bd04 100644 --- a/src/hooks/useExport.ts +++ b/src/hooks/useExport.ts @@ -255,13 +255,59 @@ export default () => { // 获取阴影配置 const getShadowOption = (shadow: PPTElementShadow): pptxgen.ShadowProps => { 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 { type: 'outer', color: c.color.replace('#', ''), opacity: c.alpha, blur: shadow.blur * 0.75, - offset: (shadow.h + shadow.v) / 2 * 0.75, - angle: 45, + offset, + angle, } }