Skip to content

Commit

Permalink
Use a temp dir instead of mutating the CairoMakie src dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed Feb 1, 2024
1 parent b833443 commit 5caa06e
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions CairoMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,14 @@ function openurl(url::String)
@warn("Can't find a way to open a browser, open $(url) manually!")
end

function display_path(type::String)
if !(type in ("svg", "png", "pdf", "eps"))
error("Only \"svg\", \"png\", \"eps\" and \"pdf\" are allowed for `type`. Found: $(type)")
end
return abspath(joinpath(@__DIR__, "display." * type))
end

function Base.display(screen::Screen, scene::Scene; connect=false)
# Nothing to do, since drawing is done in the other functions
# TODO write to file and implement upenurl
return screen
end

function Base.display(screen::Screen{IMAGE}, scene::Scene; connect=false)
path = display_path("png")
path = joinpath(mktempdir(), "display.png")
Makie.push_screen!(scene, screen)
cairo_draw(screen, scene)
Cairo.write_to_png(screen.surface, path)
Expand Down

0 comments on commit 5caa06e

Please sign in to comment.