Closed wsrinin closed 2 years ago
No, only by converting it to png... But actually, it shouldn't be tooo hard to implement a function svg -> Makie.Scene, since svg doesn't have that many drawing operations and they should be all supported by Makie. I actually tried that some time ago, but admittedly failed at parsing the xml and getting any meaningful paths + attributes out of it... Someone with more xml experience could probably do this quite a bit faster!
That is what I figure out as well. The infrastructure is there but it is gonna quite a bit of work to make it work because I was thinking about rendering the math equation as SVG or PNG use it as a texture to plot on Makie scene. I can't remember why precisely I don't want to use PNG format.
Isn't Cairo capable of doing SVG?
I guess if you stay with the cairo backend, there could be a simpler way ;) Png is resolution dependent, so if you zoom you will see ugly pixels + edges - so yeah, perfect solution would be to directly turn an svg into a makie plot!
@wsrinin Cairo is able to output SVG and librsvg can render SVG to Cairo surfaces (https://github.com/lobingera/Rsvg.jl) Do you think of 'just' putting this as background picture?
Moving SVG export discussion from #256
Unfortunately I'm having another issue with the svg export.
Looks like the backend call:
using AbstractPlotting, CairoMakie, FileIO
AbstractPlotting.current_backend[] = CairoMakie.CairoBackend("/tmp/test.svg")
#intention is to get here
#open("/tmp/test.svg","w") do io
# show(io, MIME"image/svg+xml"(), scene)
#end
changes the behavior of plotting, resulting in incorrect plots. The best way to describe is: it looks like a canvas sizing error where the original plot becomes tiled with repetition inside the original axes. For example, the correct image looks something like this (a png):
But ends up looking like this (screen grab of svg opened via eog
on Ubuntu 16.04):
Note, the Makie Window no longer shows the plots (as per this issue), but working through Juno the plot pane shows the same funky canvas version. I'm pretty sure it is related to changing to the Cairo backend.
Manim implements an SVG parser that does pretty much this in Python. What are the primitive plotting commands that should be used to make the Makie scene?
That's interesting, I will definitely give it a look!
We currently decompose all plotting commands into several 'atomic' drawing operations within AbstractPlotting - for 2d plotting, all you really need is linesegments
, lines
, mesh
, heatmap
/image
, and text
.
Also, @dehann, the issue with Cairo is being investigated in JuliaPlots/CairoMakie.jl#11.
There are probably better parsers to look at as well. This looks promising, although it parses everything into bezier curves, so semantic information is lost. Shouldn't matter just for plotting, though.
Looking at the resvg repo, it seems that it statically links harfbuzz
at runtime. That, and figuring out the C API, would be the only hiccups in getting it wrapped in Julia.
Hello,
Is there a way to render SVG file in Makie window?
Best,