diff --git a/src/hooks/useExport.ts b/src/hooks/useExport.ts index c8b41634..81c7fe61 100644 --- a/src/hooks/useExport.ts +++ b/src/hooks/useExport.ts @@ -3,7 +3,7 @@ import { trim } from 'lodash' import { saveAs } from 'file-saver' import pptxgen from 'pptxgenjs' import tinycolor from 'tinycolor2' -import { getElementRange } from '@/utils/element' +import { getElementRange, getLineElementPath } from '@/utils/element' import { AST, toAST } from '@/utils/htmlParser' import { SvgPoints, toPoints } from '@/utils/svgPathParser' import { svg2Base64 } from '@/utils/svg2Base64' @@ -292,19 +292,7 @@ export default () => { } } else if (el.type === 'line') { - let path = '' - const start = el.start.join(',') - const end = el.end.join(',') - if (el.broken) { - const mid = el.broken.join(',') - path = `M${start} L${mid} L${end}` - } - else if (el.curve) { - const mid = el.curve.join(',') - path = `M${start} Q${mid} ${end}` - } - else path = `M${start} L${end}` - + const path = getLineElementPath(el) const points = formatPoints(toPoints(path)) const { minX, maxX, minY, maxY } = getElementRange(el) diff --git a/src/utils/element.ts b/src/utils/element.ts index 95418482..574a4bf0 100644 --- a/src/utils/element.ts +++ b/src/utils/element.ts @@ -1,4 +1,5 @@ -import { PPTElement } from '@/types/slides' +import tinycolor from 'tinycolor2' +import { PPTElement, PPTLineElement } from '@/types/slides' import { createRandomCode } from '@/utils/common' interface RotatedElementData { @@ -172,4 +173,38 @@ export const createElementIdMap = (elements: PPTElement[]) => { groupIdMap, elIdMap, } +} + +/** + * 根据表格的主题色,获取对应用于配色的子颜色 + * @param themeColor 主题色 + * @returns + */ +export const getTableSubThemeColor = (themeColor: string) => { + const rgba = tinycolor(themeColor).toRgb() + const subRgba1 = { r: rgba.r, g: rgba.g, b: rgba.b, a: rgba.a * 0.3 } + const subRgba2 = { r: rgba.r, g: rgba.g, b: rgba.b, a: rgba.a * 0.1 } + return [ + `rgba(${[subRgba1.r, subRgba1.g, subRgba1.b, subRgba1.a].join(',')})`, + `rgba(${[subRgba2.r, subRgba2.g, subRgba2.b, subRgba2.a].join(',')})`, + ] +} + +/** + * 获取线条元素路径字符串 + * @param element 线条元素 + * @returns + */ +export const getLineElementPath = (element: PPTLineElement) => { + const start = element.start.join(',') + const end = element.end.join(',') + if (element.broken) { + const mid = element.broken.join(',') + return `M${start} L${mid} L${end}` + } + if (element.curve) { + const mid = element.curve.join(',') + return `M${start} Q${mid} ${end}` + } + return `M${start} L${end}` } \ No newline at end of file diff --git a/src/views/components/element/LineElement/BaseLineElement.vue b/src/views/components/element/LineElement/BaseLineElement.vue index 7f9e0ff7..747a91f3 100644 --- a/src/views/components/element/LineElement/BaseLineElement.vue +++ b/src/views/components/element/LineElement/BaseLineElement.vue @@ -53,6 +53,7 @@