mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 将渐变色添加到主题提取逻辑中
This commit is contained in:
parent
bcd8749a75
commit
e277a6abac
@ -139,6 +139,7 @@ const addPoint = (e: MouseEvent) => {
|
||||
outline: 1px solid #d9d9d9;
|
||||
box-shadow: 0 0 2px 2px #d9d9d9;
|
||||
border-radius: 1px;
|
||||
cursor: pointer;
|
||||
|
||||
&.active {
|
||||
outline: 1px solid $themeColor;
|
||||
|
@ -31,8 +31,9 @@ export default () => {
|
||||
backgroundColorValues.push({ area: 1, value: slide.background.color })
|
||||
}
|
||||
else if (slide.background.type === 'gradient' && slide.background.gradient) {
|
||||
const len = slide.background.gradient.colors.length
|
||||
backgroundColorValues.push(...slide.background.gradient.colors.map(item => ({
|
||||
area: 1,
|
||||
area: 1 / len,
|
||||
value: item.color,
|
||||
})))
|
||||
}
|
||||
@ -54,6 +55,13 @@ export default () => {
|
||||
if (el.fill) {
|
||||
themeColorValues.push({ area, value: el.fill })
|
||||
}
|
||||
if (el.type === 'shape' && el.gradient) {
|
||||
const len = el.gradient.colors.length
|
||||
themeColorValues.push(...el.gradient.colors.map(item => ({
|
||||
area: 1 / len * area,
|
||||
value: item.color,
|
||||
})))
|
||||
}
|
||||
|
||||
const text = (el.type === 'shape' ? el.text?.content : el.content) || ''
|
||||
if (!text) continue
|
||||
@ -160,8 +168,8 @@ export default () => {
|
||||
for (const item of backgroundColorValues) {
|
||||
const color = tinycolor(item.value).toRgbString()
|
||||
if (color === 'rgba(0, 0, 0, 0)') continue
|
||||
if (!backgroundColors[color]) backgroundColors[color] = 1
|
||||
else backgroundColors[color] += 1
|
||||
if (!backgroundColors[color]) backgroundColors[color] = item.area
|
||||
else backgroundColors[color] += item.area
|
||||
}
|
||||
|
||||
const themeColors: { [key: string]: number } = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user