I’d like to have two views of the same scene / data in Makie. Below is code for the output that I want, but I would like to just have one call to scatter!
(for example).
using Makie: Makie, Observable
using GLMakie: GLMakie
using GeometryBasics: HyperRectangle
fig = Makie.Figure()
ax1 = Makie.Axis(fig[1, 1])
ax2 = Makie.Axis(fig[1, 2])
for ax in [ax1, ax2]
Makie.scatter!(ax, [(0, 0), (1, 0), (0, 1)]; markersize=100)
end
window_size = (0.5, 0.5)
window_center = Observable((0.0, 0.0))
function make_rect_loop(center, size)
ms = [(1, 1), (1, -1), (-1, -1), (-1, 1), (1, 1)]
[center .+ (m .* size) for m in ms]
end
function make_rect(center, size)
origin = center .- (size ./ 2)
HyperRectangle{length(origin)}(origin, size)
end
window_corners = Makie.lift(c -> make_rect_loop(c, window_size), window_center)
viewport = Makie.lift(c -> make_rect(c, window_size), window_center)
# TODO endcap of path is not correct (does not close)
Makie.lines!(ax1, window_corners, color=:black, linewidth=5)
Makie.on(viewport) do vp
Makie.limits!(ax2, vp)
end
display(fig)
secs = 3
framerate = 15
Makie.record(fig, "eg.mp4", 1:(secs * framerate); framerate) do i
s = i / framerate
kv = [(0, 0), (1, 0), (0, 1), (0, 0)]
kt = [0.0, 1.0, 2.0, 3.0]
# linear interpolation
s_i = searchsortedfirst(kt, s)
i1 = max(s_i - 1, firstindex(kv))
i2 = min(s_i, lastindex(kv))
Δ = kt[i2] - kt[i1][Processing: eg.mp4...]()
![eg|666x500](upload://6ht3x3ajm1XSbU9sbe01qPvvjU9.gif)
p = ifelse(Δ == 0, 0.5, (s - kt[i1]) / Δ)
v_s = kv[i1] .* (1 - p) .+ kv[i2] .* (p)
window_center[] = v_s
end
I’d also like to know what call truly forces the Axes
limits, so that the black rectangle corresponds to the viewport of the right plot.