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

Replace write_to_png and write_to_svg by write #42

Closed
MaximeBouton opened this issue Feb 21, 2020 · 6 comments · Fixed by #43
Closed

Replace write_to_png and write_to_svg by write #42

MaximeBouton opened this issue Feb 21, 2020 · 6 comments · Fixed by #43

Comments

@MaximeBouton
Copy link
Member

No description provided.

MaximeBouton added a commit that referenced this issue Feb 22, 2020
@MaximeBouton MaximeBouton mentioned this issue Feb 22, 2020
@mattuntergassmair
Copy link
Collaborator

mattuntergassmair commented Mar 1, 2020

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
Copy link
Member Author

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.

  • Any CairoSurface can be saved as .png
  • For saving to svg or pdf it would need the correct surface type. If it is not the correct type, the write function could return an error message that tells how to fix it.

@MaximeBouton
Copy link
Member Author

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

@mattuntergassmair
Copy link
Collaborator

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
Copy link
Member Author

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

@MaximeBouton
Copy link
Member Author

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

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

Successfully merging a pull request may close this issue.

2 participants