Skip to content

Commit

Permalink
更新颜色叠加效果
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Jan 23, 2024
1 parent 17f44bd commit 29ceb97
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/hooks/useHandleTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export default () => {
* 移动页面焦点
* @param command 移动页面焦点命令:上移、下移
*/
const updateTemplateIndex = (command: string) => {
const updateTemplateIndex = async (command: string) => {
if (command === KEYS.UP && templateIndex.value > 0) {
templatesStore.setTemplateIndex(templateIndex.value - 1)
}
else if (command === KEYS.DOWN && templateIndex.value < templates.value.length - 1) {
templatesStore.setTemplateIndex(templateIndex.value + 1)
}
templatesStore.renderTemplate()
await templatesStore.renderTemplate()
}

// 将当前页面数据加密后复制到剪贴板
Expand Down Expand Up @@ -99,10 +99,10 @@ export default () => {
await templatesStore.renderTemplate()
}

const addTemplate = (template: Template) => {
templatesStore.addTemplate(template)
const addTemplate = async (template: Template) => {
await templatesStore.addTemplate(template)
templatesStore.setTemplateIndex(templateIndex.value)
templatesStore.renderTemplate()
await templatesStore.renderTemplate()
}

// // 根据模板创建新页面
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ export const useTemplatesStore = defineStore('Templates', {

setObjectFilter(objects: CanvasElement[]) {
objects.forEach(ele => {
if (ele.type === ElementNames.IMAGE) {
if (ele.type.toLowerCase() === ElementNames.IMAGE) {
this.setImageFilter(ele as ImageElement)
}
if (ele.type === ElementNames.GROUP) {
if (ele.type.toLowerCase() === ElementNames.GROUP) {
this.setObjectFilter(((ele as GroupElement).objects) as CanvasElement[])
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/views/Canvas/useFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const findElement = (eid: string, elements: CanvasElement[] | undefined): Canvas
if (item.id === eid) {
return item
}
if (item.type === ElementNames.GROUP) {
if (item.type.toLowerCase() === ElementNames.GROUP) {
return findElement(eid, ((item as GroupElement).objects) as CanvasElement[])
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/worker/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ self.onmessage = async (e) => {
}
else if (type === 'filter') {
const { src, pixiFilters, width, height, id } = e.data
// app?.renderer.clear()
app?.renderer.clear()
app?.renderer.resize(width, height)
const texture = await Texture.fromURL(src)
const sprite = new Sprite(texture)
Expand All @@ -30,6 +30,7 @@ self.onmessage = async (e) => {
handleColorGradientFilter(ele as PixiColorGradientFilter, sprite.filters)
}
}
console.log('sprite.filters:', sprite.filters)
app?.stage.addChild(sprite)
const res = await app?.renderer.plugins.extract.base64(sprite)
const data = {res, id}
Expand Down

0 comments on commit 29ceb97

Please sign in to comment.