Skip to content
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

Add state and blendMode property to MaskData #7969

Open
wants to merge 1 commit into
base: v7.x
Choose a base branch
from

Conversation

dev7355608
Copy link
Collaborator

Description of change

Added state and blendMode properties to MaskData for sprite masks.

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

@bigtimebuddy bigtimebuddy added this to the v6.3.0 milestone Nov 7, 2021
@bigtimebuddy
Copy link
Member

Thanks @dev7355608. Could you explain more about why you'd need to provide a blendMode for a MaskData? Not sure I understand the use-case visually.

@dev7355608
Copy link
Collaborator Author

@bigtimebuddy Sprite masks are currently always blended with the NORMAL blend mode. A workaround would be this:

object.mask = new PIXI.MaskData(sprite);
object.mask.filter = new PIXI.SpriteMaskFilter();
object.mask.filter.blendMode = PIXI.BLEND_MODES.ADD;

Before custom sprite mask filters it was impossible to use a mask in this case, and you would have needed to add a filter directly.

object.filters = [new PIXI.SpriteMaskFilter(sprite)];
object.filters[0].blendMode = PIXI.BLEND_MODES.ADD;

If the mask filter's resolution/multisample/enabled are overridden the corresponding properties of MaskData , then so should state/blendMode:

object.mask = new PIXI.MaskData(sprite);
object.mask.blendMode = PIXI.BLEND_MODES.ADD;

@bigtimebuddy bigtimebuddy removed this from the v6.3.0 milestone Feb 7, 2022
@bigtimebuddy
Copy link
Member

@dev7355608 could you provide a visual example of this?

@dev7355608
Copy link
Collaborator Author

Imagine any scenario where you want to blend an object with anything other than NORMAL, but also want to apply a sprite mask to the object. The default filter of the sprite mask is always blended with NORMAL, but you might want to MULTIPLY after the sprite mask was applied to the object. As I mentioned above it's possible to work around this by using a custom filter and setting the blend mode of it. But all other filter properties except the state are part of mask data already, so I think, for this reason, it makes sense to add the state (and blendMode) to MaskData as well.

@bigtimebuddy bigtimebuddy added the 🥶 Low Priority Generally issues or PRs that don’t need to make it into the next release. label May 24, 2023
@Zyie Zyie deleted the branch pixijs:v7.x March 5, 2024 17:16
@Zyie Zyie closed this Mar 5, 2024
@Zyie Zyie reopened this Mar 5, 2024
@Zyie Zyie changed the base branch from dev to v7.x March 5, 2024 18:08
@Zyie Zyie added the v7 label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🥶 Low Priority Generally issues or PRs that don’t need to make it into the next release. v7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants