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

Alpha channel for color behaves inconsistently between web and desktop #606

Closed
Tracked by #552
RybekU opened this issue May 9, 2020 · 5 comments
Closed
Tracked by #552
Labels
bug Some API breaks the contract it establishes subsystem-graphics

Comments

@RybekU
Copy link

RybekU commented May 9, 2020

Description
Using Color::with_alpha on web and locally produces different results as illustrated on image below:
obraz
Left rectangle - web
Right rectangle - desktop application
To Reproduce
Background color is Color::CYAN.
Rectangle is created using:

  gfx.fill_rect(&area, Color::BLUE.with_alpha(0.2));
  gfx.stroke_rect(&area, Color::BLUE);

Environment and versions:

  • Environment: Windows 10 and Firefox
  • Rust compiler version: stable
  • Quicksilver version: commit rev = "8fdff10"
@ryanisaacg ryanisaacg added bug Some API breaks the contract it establishes subsystem-graphics labels May 15, 2020
@ryanisaacg
Copy link
Owner

That's... interesting! I'll read the specs on blending for WebGL vs Desktop GL to see if there's anything that jumps out at me. I hope this is an easy fix but I can't promise that it will be.

@lenscas
Copy link
Contributor

lenscas commented May 15, 2020

So... here is an interesting one. I decided to check the difference for myself mostly because I was curious and although the build for native looks quite similar to what is on the right. When I use cargo web to build for the web the square seems to become green

image

Also, if I change the background color to white, the square becomes yellow instead.

image

Browser:76.0.1 (64-bit)
OS: Linux
Quicskilver version: d105757

In order to produce this, I simply cloned quicksilver and changed the 01_example to contain the above mentioned code.

@AnthonyYoManz
Copy link

AnthonyYoManz commented May 17, 2020

Pretty sure this is caused by the alpha-blending happening against the web-page. If you change the body element's background color to white and run some code that draws a semi-transparent black square over a sprite then the sprite will be blended with white. If you change the body element's background colour to black and repeat the process, the sprite will be blended with black.

@ryanisaacg
Copy link
Owner

Both issues here should be resolved by ryanisaacg/blinds#28: the alpha should show up the same on desktop and web, and the canvas should not be blended with the page background.

@ryanisaacg
Copy link
Owner

Let me know if either of these issues crop up after you upgrade dependencies, but the new blinds version should take care of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Some API breaks the contract it establishes subsystem-graphics
Projects
None yet
Development

No branches or pull requests

4 participants