Closed AliFlux closed 2 years ago
P.S. It works perfectly fine if I replace drawCanvas with drawImage. But the svg is rasterized
This seems to be a limitation of Skia's current SVG support (which they still label as ‘experimental’ so it’s not entirely surprising). The issue is that the method we’re using to draw the canvas has this restriction:
If paint is non-null, then the picture is always drawn into a temporary layer before actually landing on the canvas. Note that drawing into a layer can also change its appearance if there are any non-associative blendModes inside any of the pictures elements.
The ‘paint’ in question is necessary for applying:
globalAlpha
(if < 1.0)globalCompositeOperation
(if not source-over
)filter
settingsThe bitmap and PDF renderers don’t have a problem with this, but for SVG output it seems that the entire layer gets omitted if the paint argument is even included.
It’s only a partial fix, but I can change the drawCanvas
method to only apply the paint when the alpha/blend/filter/shadow settings are using non-default values. That should make SVG exports work so long as you don’t change the opacity, blend mode, or filters on the destination canvas.
This modification was added in the 1.0 release.
Hi.
Thanks for making this amazing library. I came across this weird problem where svg was fully blank when drawCanvas was used. Any idea what could be the problem?
This is supposed to be the result: