-
Notifications
You must be signed in to change notification settings - Fork 76
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
Applying an SVG filter to the canvas #157
Comments
There is currently no support for any SVG features at all, nor is there anything to handle Skia itself must support it, but I have no idea about skia-safe (the intermediate library layer used by skia-canvas), or what would be involved in implementing it. Just being able to load SVGs natively would be a great start. |
It looks like Skia itself has SVG support. I couldn't find a library with the term I don't know that I know how to implement it either. It would be great to have. Basically, I'm trying to apply filters to canvas elements server side and the filters Skia Canvas support are the CSS filters (except URL()) but they are somewhat primitive if IIUC. The URL() CSS filter would allow SVG filters which seem to offer much wider range. Although, if it was possible, having a way to apply multiple filters in code might solve the issue. Something like:
|
Yea, sorry, "Rust Skia" is what I meant (it's called "skia safe" in the Rust package manager for some reason). And from what I understand it support most, if not all, Skia features. But skia-canvas only implements a subset. There's PR #155 which would probably be a good place to start on updating. Perhaps I misunderstand what you mean, but multiple filters can be added now like in the standard, by separating the filter functions with spaces in the Cheers, |
I'm aware of adding multiple filters inline. What I meant by adding multiple filters manually was to do it longhand in JavaScript code rather than by string values. So instead of:
something like this:
I'd rather create the filter objects and set values on them if that makes sense. Some of my past experience in image data filters make sense and some areas I've still got more to learn. |
Well there's no "filter object type" in standard JS that I know of, and the context You could have your filter objects output a string as a result, collect them into an array (eg. That's actually almost exactly what I've done in some code where the app's users can add arbitrary canvas filters as image layers. |
Totally OT now, but if there was a built-in way to track added filters so that they can later be reset automatically, w/out having to specify the filter again with "no op" values (eg. |
Indeed. One would hope that there would be class references for all the HTML and SVG markup elements that exist. So that they could be applied and modified like you describe. I have to pass on this library for now but will check back periodically for this support. For now, I believe my only option is to try client side. |
If there's anything I can do to help push this along (besides writing the code - I'm unable to contribute at this moment) let me know. |
The documentation says, "Skia canvas supports the full set of CSS filter image processing operators"
In the examples I've seen applying a filter is as simple as setting the filter property:
The CSS filter documentation mentions the URL() filter:
How would I do the same in Skia Canvas?
Could it be embedded? Will it load an external file?
Embedded:
External:
I realize now I can probably test this. However, I didn't find any examples in the documentation.
The text was updated successfully, but these errors were encountered: