sisl / AutoViz.jl

Provides visualization tools for AutomotiveDrivingModels. Built on Cairo
Other
33 stars 9 forks source link

Replace `write_to_png` and `write_to_svg` by `write` #42

Closed MaximeBouton closed 4 years ago

mattuntergassmair commented 4 years ago

I think the way we have currently solved this is not sufficient, as it allows syntax such as

c = render([roadway])
write("stadium.svg", c) # all good
write("stadium.png", c) # saves with .png suffix, but is actually an svg

We should really implement this in a way that the format of the file is deduced from the filename suffix (I think the plotting package does something very similar)

MaximeBouton commented 4 years ago

One of the challenge is that depending on the type of c we would not be able to save in any format, but I guess we could return an error message in that case.

MaximeBouton commented 4 years ago

I will try to implement that soon, let's wait for this feature before merging #43

mattuntergassmair commented 4 years ago

Cool, sounds good. Yeah I'd say erroring is fine in that case and we can always leave write_to_svg etc. around and then just call that function from within Base.write() for convenience.

MaximeBouton commented 4 years ago

Distinguishing between svg and pdf is not trivial as CairoPDFSurface and CairoSVGSurface are actually of the same type (CairoSurfaceIOStream{UInt32}).

MaximeBouton commented 4 years ago

I think it should be solved in #43 now, related issue JuliaGraphics/Cairo.jl#316