Add and change points


using LinearAlgebra

using AbstractPlotting

img = rand(100, 100)
scene = Scene(scale_plot = false, resolution = (500, 500))
heatmap!(scene, img)
clicks = Node(Point2f0[(0, 0)])
blues = Node(Point2f0[])
on(scene.events.mousebuttons) do buttons
    if ispressed(scene, Mouse.left)
        pos = to_world(scene, Point2f0(scene.events.mouseposition[]))
        found = -1
        c = clicks[]
        for i in 1:length(c)
           if norm(pos - c[i]) < 1
               found = i
           end
        end
        if found >= 1
            blues[] = push!(blues[], pos)
            deleteat!(clicks[], found)
        else
            push!(clicks[], pos)
        end
        clicks[] = clicks[]
   end
   return
end
t = Theme(markersize = 10, raw = true)
scatter!(scene, t, clicks, color = :red, marker = '+')
red_clicks = scene[end]
scatter!(scene, t, blues, color = :blue, marker = 'o')
center!(scene)

# Do not execute beyond this point!

RecordEvents(scene, "output")