Is it possible and how to plot into an existing buffer with Makie.jl
? My guess is that Cairomakie.jl
would be the choice, but I can’t find a solution for it.
The reason for this task is, that I want to hand over the buffer to a C library several times.
Here is an example for a 3D plot (from gallery Beautiful Makie) without the buffer:
using ImageView
using CairoMakie
CairoMakie.activate!()
x = -2:0.005:2
y = -2:0.005:2
f(z) = (z^2 + 1) / (z^2 - 1)
fvals = [f(u + 1im * v) for u in x, v in y]
fvalues = abs.(fvals)
fargs = angle.(fvals)
indxCut = fvalues .> 3
fvalues[indxCut] .= 3.01
fig, ax, pltobj = surface(x, y, fvalues, color = fargs,
colormap = :roma, colorrange = (-π, π),
backlight = 1.0f0, highclip = :black,
figure = (; size = (800, 600), fontsize = 22));
display(fig)
imshow(colorbuffer(fig.scene))
Here is some pseudocode for what I want to do
using CairoMakie
CairoMakie.activate!()
buffer=zeros(RGB24, 800, 600)
function draw_into_buffer!(buffer)
x = -2:0.005:2
y = -2:0.005:2
f(z) = (z^2 + 1) / (z^2 - 1)
fvals = [f(u + 1im * v) for u in x, v in y]
fvalues = abs.(fvals)
fargs = angle.(fvals)
indxCut = fvalues .> 3
fvalues[indxCut] .= 3.01
#PSEUDOCODE: plot into existing buffer:
surface_into_buffer(buffer, x, y, fvalues, color = fargs,
colormap = :roma, colorrange = (-π, π),
backlight = 1.0f0, highclip = :black,
figure = (; size = (1200, 800), fontsize = 22));
end
draw_into_buffer!(buffer);
#provide buffer to some C library as pointer(buffer)
How can I tell CairoMakie to plot into an existing buffer for image pixels?
The prefered idea is not to copy again and again from colorbuffer(fig.scene)
to buffer
for performance.