From 02224738af2f5876c15f89ad3be6baa0fdca0814 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Mon, 28 Feb 2022 10:19:41 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=83=A8=E5=88=86=E5=BD=A2=E7=8A=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/shapes.ts | 17 +++++++++++++++-- src/types/slides.ts | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/configs/shapes.ts b/src/configs/shapes.ts index cf6277ad..a6fc8e33 100644 --- a/src/configs/shapes.ts +++ b/src/configs/shapes.ts @@ -41,6 +41,17 @@ export const SHAPE_PATH_FORMULAS = { const radius = Math.min(width, height) / 8 return `M 0 ${radius} Q 0 0 ${radius} 0 L ${width - radius} 0 Q ${width} 0 ${width} ${radius} L ${width} ${height} L 0 ${height} Z` }, + [ShapePathFormulasKeys.MESSAGE]: (width: number, height: number) => { + const arrowWidth = width / 5 + const arrowheight = height / 5 + return `M 0 0 L ${width} 0 L ${width} ${height - arrowheight} L ${width / 2} ${height - arrowheight} L ${width / 2 - arrowWidth} ${height} L ${width / 2 - arrowWidth} ${height - arrowheight} L 0 ${height - arrowheight} Z` + }, + [ShapePathFormulasKeys.ROUND_MESSAGE]: (width: number, height: number) => { + const radius = Math.min(width, height) / 8 + const arrowWidth = width / 5 + const arrowheight = height / 5 + return `M 0 ${radius} Q 0 0 ${radius} 0 L ${width - radius} 0 Q ${width} 0 ${width} ${radius} L ${width} ${height - radius - arrowheight} Q ${width} ${height - arrowheight} ${width - radius} ${height - arrowheight} L ${width / 2} ${height - arrowheight} L ${width / 2 - arrowWidth} ${height} L ${width / 2 - arrowWidth} ${height - arrowheight} L ${radius} ${height - arrowheight} Q 0 ${height - arrowheight} 0 ${height - radius - arrowheight} L 0 ${radius} Z` + }, } export const SHAPE_LIST: ShapeListItem[] = [ @@ -210,11 +221,13 @@ export const SHAPE_LIST: ShapeListItem[] = [ }, { viewBox: [200, 200], - path: 'M 0 0 L 200 0 L 200 160 L 100 160 L 60 200 L 60 160 L 0 160 L 0 0 Z' + path: 'M 0 0 L 200 0 L 200 160 L 100 160 L 60 200 L 60 160 L 0 160 Z', + pathFormula: ShapePathFormulasKeys.MESSAGE, }, { viewBox: [200, 200], - path: 'M 0 40 Q 0 0 40 0 L 160 0 Q 200 0 200 40 L 200 120 Q 200 160 160 160 L 100 160 L 60 200 L 60 160 L 40 160 Q 0 160 0 120 L 0 40 Z' + path: 'M 0 40 Q 0 0 40 0 L 160 0 Q 200 0 200 40 L 200 120 Q 200 160 160 160 L 100 160 L 60 200 L 60 160 L 40 160 Q 0 160 0 120 L 0 40 Z', + pathFormula: ShapePathFormulasKeys.ROUND_MESSAGE, }, { viewBox: [200, 200], diff --git a/src/types/slides.ts b/src/types/slides.ts index baf84d6e..4b9b009f 100644 --- a/src/types/slides.ts +++ b/src/types/slides.ts @@ -8,6 +8,8 @@ export const enum ShapePathFormulasKeys { CUT_RECT_DIAGONAL = 'cutRectDiagonal', CUT_RECT_SINGLE = 'cutRectSingle', CUT_RECT_SAMESIDE = 'cutRectSameSide', + MESSAGE = 'message', + ROUND_MESSAGE = 'roundMessage', } export const enum ElementTypes {