-
-
Notifications
You must be signed in to change notification settings - Fork 320
feat: add blend mode argument #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MakinoharaShoko
merged 1 commit into
OpenWebGAL:dev
from
HardyNLee:feat/figure-blend-mode
Jan 27, 2026
+55
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { BevelFilter } from '@/Core/controller/stage/pixi/shaders/BevelFilter'; | |
| import * as PIXI from 'pixi.js'; | ||
| import { BlurFilter } from '@pixi/filter-blur'; | ||
| import { INIT_RAD, RadiusAlphaFilter } from '@/Core/controller/stage/pixi/shaders/RadiusAlphaFilter'; | ||
| import { logger } from '@/Core/util/logger'; | ||
|
|
||
| /** | ||
| * Filter configuration for creation and default state detection. | ||
|
|
@@ -347,6 +348,40 @@ export class WebGALPixiContainer extends PIXI.Container { | |
| this.alphaFilter.alpha = v; | ||
| } | ||
|
|
||
| public get blendMode(): string { | ||
| switch (this.alphaFilter.blendMode) { | ||
| case PIXI.BLEND_MODES.NORMAL: | ||
| return 'normal'; | ||
| case PIXI.BLEND_MODES.ADD: | ||
| return 'add'; | ||
| case PIXI.BLEND_MODES.MULTIPLY: | ||
| return 'multiply'; | ||
| case PIXI.BLEND_MODES.SCREEN: | ||
| return 'screen'; | ||
| default: | ||
| logger.warn(`Unknown blend mode: ${this.alphaFilter.blendMode}, returning normal.`); | ||
| return 'normal'; | ||
| } | ||
| } | ||
| public set blendMode(v: string) { | ||
| switch (v) { | ||
| case 'normal': | ||
| this.alphaFilter.blendMode = PIXI.BLEND_MODES.NORMAL; | ||
| break; | ||
| case 'add': | ||
| this.alphaFilter.blendMode = PIXI.BLEND_MODES.ADD; | ||
| break; | ||
| case 'multiply': | ||
| this.alphaFilter.blendMode = PIXI.BLEND_MODES.MULTIPLY; | ||
| break; | ||
| case 'screen': | ||
| this.alphaFilter.blendMode = PIXI.BLEND_MODES.SCREEN; | ||
| break; | ||
| default: | ||
| logger.warn(`Unknown blend mode: ${v}, setting to normal.`); | ||
| this.alphaFilter.blendMode = PIXI.BLEND_MODES.NORMAL; | ||
| } | ||
| } | ||
|
Comment on lines
+351
to
+384
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为了提高代码的可维护性和可扩展性,建议使用映射(Map/Object)来处理字符串和 为了获得最佳性能,建议将这些映射对象提取为类的静态属性。 public get blendMode(): string {
const reverseBlendModeMap: Record<number, string> = {
[PIXI.BLEND_MODES.NORMAL]: 'normal',
[PIXI.BLEND_MODES.ADD]: 'add',
[PIXI.BLEND_MODES.MULTIPLY]: 'multiply',
[PIXI.BLEND_MODES.SCREEN]: 'screen',
};
const blendModeName = reverseBlendModeMap[this.alphaFilter.blendMode];
if (blendModeName) {
return blendModeName;
}
logger.warn(`Unknown blend mode: ${this.alphaFilter.blendMode}, returning normal.`);
return 'normal';
}
public set blendMode(v: string) {
const blendModeMap: Record<string, PIXI.BLEND_MODES> = {
normal: PIXI.BLEND_MODES.NORMAL,
add: PIXI.BLEND_MODES.ADD,
multiply: PIXI.BLEND_MODES.MULTIPLY,
screen: PIXI.BLEND_MODES.SCREEN,
};
const blendMode = blendModeMap[v];
if (blendMode !== undefined) {
this.alphaFilter.blendMode = blendMode;
} else {
logger.warn(`Unknown blend mode: ${v}, setting to normal.`);
this.alphaFilter.blendMode = PIXI.BLEND_MODES.NORMAL;
}
} |
||
| public removeFilterByName(filterName: string) { | ||
| const filter = this.containerFilters.get(filterName); | ||
| if (!filter || !this.filters) return; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分应用元数据的逻辑在
addLive2dFigure和addFigure方法中是重复的。为了减少代码重复并提高可维护性,建议将这部分逻辑提取到一个私有辅助方法中。例如,可以创建一个
applyFigureMetadata方法:然后在
addFigure和addLive2dFigure中调用this.applyFigureMetadata(thisFigureContainer, key);来替代重复的代码块。