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

Make CSS filters work with CanvasFilter #22

Open
tomayac opened this issue Nov 2, 2021 · 3 comments
Open

Make CSS filters work with CanvasFilter #22

tomayac opened this issue Nov 2, 2021 · 3 comments

Comments

@tomayac
Copy link

tomayac commented Nov 2, 2021

Right now, there are two ways to provide filters: one for "simple" CSS filters (example: offscreenCanvas.filter = 'brightness(1)') and one for more complex SVG filters (example: offscreenCanvas.filter = new CanvasFilter([…])). Ideally, simple CSS filters could be modeled as {filter: 'brightness', amount: 1} as well, so they can all be passed in one big filter array.

@Kaiido
Copy link

Kaiido commented Dec 4, 2021

I wonder if passing the CSS strings directly in the filter property wouldn't be better here instead of "inventing" new properties which doesn't really map to anything (e.g what should be the properties for drop-shadow). So maybe something like the following could do?

new CanvasFilter([
  {
    filter: "convolveMatrix", 
    kernelMatrix: [ ... ]
  },
  {
    filter: "brightness(70%)"
  }
]);

cc @mysteryDate

@tomayac
Copy link
Author

tomayac commented Dec 6, 2021

I wonder if passing the CSS strings directly in the filter property wouldn't be better[.]

This would work for me.

@mysteryDate
Copy link
Collaborator

@Kaiido I like that solution too, will be very easy to implement and test.

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

No branches or pull requests

3 participants