diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index d6ab3f7e62c..24432b071c6 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -342,7 +342,6 @@ function apply_config!(screen::Screen, config::ScreenConfig; start_renderloop::B replace_processor!(config.fxaa ? fxaa_postprocessor : empty_postprocessor, 3) # Set the config screen.config = config - @show start_renderloop if start_renderloop start_renderloop!(screen) else diff --git a/ReferenceTests/src/tests/short_tests.jl b/ReferenceTests/src/tests/short_tests.jl index 57baa421b1e..c939fc60626 100644 --- a/ReferenceTests/src/tests/short_tests.jl +++ b/ReferenceTests/src/tests/short_tests.jl @@ -257,6 +257,31 @@ end f end +@reference_test "colorbuffer for axis" begin + fig = Figure() + ax1 = Axis(fig[1, 1]) + ax2 = Axis(fig[1, 2]) + ax3 = Axis(fig[2, 2]) + ax4 = Axis(fig[2, 1]) + scatter!(ax1, 1:10, 1:10; markersize=50, color=1:10) + scatter!(ax2, 1:10, 1:10; markersize=50, color=:red) + heatmap!(ax3, -8:0.1:8, 8:0.1:8, (x, y) -> sin(x) + cos(y)) + meshscatter!(ax4, 1:10, 1:10; markersize=1, color=:red) + img1 = colorbuffer(ax1; include_decorations=true) + img2 = colorbuffer(ax2; include_decorations=false) + img3 = colorbuffer(ax3; include_decorations=true) + img4 = colorbuffer(ax4; include_decorations=false) + f, ax5, pl = image(rotr90(img1); axis=(; aspect=DataAspect())) + ax6, pl = image(f[1, 2], rotr90(img2); axis=(; aspect=DataAspect())) + ax7, pl = image(f[2, 2], rotr90(img3); axis=(; aspect=DataAspect())) + ax8, pl = image(f[2, 1], rotr90(img4); axis=(; aspect=DataAspect())) + hidedecorations!(ax5) + hidedecorations!(ax6) + hidedecorations!(ax7) + hidedecorations!(ax8) + f +end + # Needs a way to disable autolimits on show # @reference_test "interactions after close" begin diff --git a/src/display.jl b/src/display.jl index fc957a83550..30b7c10ef74 100644 --- a/src/display.jl +++ b/src/display.jl @@ -417,17 +417,6 @@ function get_sub_picture(image, format::ImageStorageFormat, rect) return image[start:stop, xmin:xmax] end -function colorbuffer(ax::Axis; include_decorations=true, update=true) - bb = if include_decorations - bb = Makie.boundingbox(ax.blockscene) - Rect2{Int}(round.(Int, minimum(bb)) .+ 1, round.(Int, widths(bb))) - else - pixelarea(ax.scene)[] - end - img = colorbuffer(root(ax.scene); update=update) - return get_sub_picture(img, JuliaNative, bb) -end - """ colorbuffer(scene, format::ImageStorageFormat = JuliaNative; update=true, backend=current_backend(), screen_config...) diff --git a/src/makielayout/blocks/axis.jl b/src/makielayout/blocks/axis.jl index 4151a899207..8656998749a 100644 --- a/src/makielayout/blocks/axis.jl +++ b/src/makielayout/blocks/axis.jl @@ -1785,3 +1785,30 @@ function attribute_examples(::Type{Axis}) ], ) end + +function axis_bounds_with_decoration(axis::Axis) + # Filter out the zoomrect + background plot + lims = Makie.data_limits(axis.blockscene.plots, p -> p isa Mesh || p isa Poly) + return Makie.parent_transform(axis.blockscene) * lims +end + +""" + colorbuffer(ax::Axis; include_decorations=true, colorbuffer_kws...) + +Gets the colorbuffer of the `Axis` in `JuliaNative` image format. +If `include_decorations=false`, only the inside of the axis is fetched. +""" +function colorbuffer(ax::Axis; include_decorations=true, update=true, colorbuffer_kws...) + if update + update_state_before_display!(ax) + end + bb = if include_decorations + bb = axis_bounds_with_decoration(ax) + Rect2{Int}(round.(Int, minimum(bb)) .+ 1, round.(Int, widths(bb))) + else + pixelarea(ax.scene)[] + end + + img = colorbuffer(root(ax.scene); update=false, colorbuffer_kws...) + return get_sub_picture(img, JuliaNative, bb) +end