-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Context Opacity Not Working as Intended #2440
Comments
Hi @robly18 thanks for the issue! Definitely seems like a bug. I'll have some time this week to dig in, I appreciate the detailed issue and workaround👍 |
I think I've figured out what is wrong here, I'll have a PR up soon 👍 |
@robly18 You definitely nailed the likely code issue! We weren't respecting the current context's opacity |
eonarheim
added a commit
that referenced
this issue
Aug 3, 2022
5 tasks
eonarheim
added a commit
that referenced
this issue
Aug 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to Reproduce
Minimal working example:
Expected Result
Notice the definition of
onPreDraw
in the previous example:Then, it would be expected that everything subsequently drawn would have its opacity multiplied by 0.2, creating a collection of transparent rectangles.
Actual Result
The two rectangle actors (
paddle
andpaddle2
) are drawn with no opacity. This could be attributed to thinking "if everything is transparent, nothing is transparent", but that's where theCustomDraw
system comes in. It draws a rectangle on screen using the graphics context, and indeed this rectangle is drawn with transparency.Potential Cause
I didn't rife through the source code, so I may be off-base, but I suspect that somewhere in the actor drawing code there is a line which sets the opacity instead of multiplying it. I can tell this is not intended behavior, as in Graphics.ts we have the following code:
My suspicion is that somewhere is something along the lines of
ex.opacity = this.opacity
instead.Partial Workaround
The intended behavior (transparency inside a certain scope) can be partially obtained by using a transparent tint, e.g.
ctx.tint = ex.Color.Transparent
. This is only a partial solution, as it does not work at all on black objects (is this intended?) and appears to wash out the color of everything else.The text was updated successfully, but these errors were encountered: