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

Document behaviour of Display.clear() and transparent bg color #167

Open
glfmn opened this issue Oct 23, 2019 · 3 comments
Open

Document behaviour of Display.clear() and transparent bg color #167

glfmn opened this issue Oct 23, 2019 · 3 comments

Comments

@glfmn
Copy link

glfmn commented Oct 23, 2019

Under the current behavior with the canvas-backed display, using a transparent background (for example #00000000) makes all options to overwrite previously drawn pixels fail to function. I assume that this might be because the default behavior with transparency is to blend to the existing pixels to rather than replace them completely.

I wanted to use a transparent background so the color would not conflict with the CSS for the rest of the site. I have been able to work around this by using the CSS variable which sets the background color with:

let display = new Display({
      fg: getComputedStyle(tile.current).getPropertyValue('--fg'),
      bg: getComputedStyle(tile.current).getPropertyValue('--bg'),
})

It would be nice to document that the clear function will not draw over pixels if the background color is transparent, or otherwise change this behavior.

@glfmn glfmn changed the title Document perils of clear and transparent backgrounds Document behaviour of Display.clear() and transparent bg color Oct 23, 2019
@ondras
Copy link
Owner

ondras commented Oct 24, 2019

Hi @glfmn,

thanks for the report. I will try to either add this to the documentation or come up with a fix so that clearing with transparency actually does stuff :)

@ondras
Copy link
Owner

ondras commented Oct 27, 2019

Hi @glfmn,

can you please provide an example that demonstrates the difficulties you are running into? I just tried https://jsfiddle.net/f5b4veca/ and it seems to work both in Firefox and Chrome. I might be missing some crucial point, though.

@ondras
Copy link
Owner

ondras commented Oct 27, 2019

Never mind, please ignore my previous example. I obviously forgot that individual calls are batched per requestAnimationFrame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants