I want to achieve something like the following:
Basically, on clicking one of the boxes, they change the state from black and white. And there is script that changes the state of all boxes.
(link to the website: Document )
I tried using GLMakie. But I am not able to get the plot in just black and white pixels. It gets me plot in Grey scale and I am not able to update the plot as well.
(There was a post recently for updating plot using GlMakie and gave red pluses on update. But I dont know how to change the pixels individually. Link: The best approach to interact with images by clicking on them and retreiving position of the pixel I clicked on)
I thought of using Gtk’s button as black and white boxes. But again, I was not able to implement this style of boxes in glade. So I used grids and buttons. But they look ugly and its cumbersome to do in gtk anyways.
Anyone got references or tutorial or documentation for this thing?
Update: I used interpolate and GlMakie with the “on click do event” script.
using GLMakie
GLMakie.activate!(inline=false)
img = rand((0,1),(20,20))
fig, ax = image(img,interpolate = false)
on(events(fig).mousebutton, priority=0) do event
if event.button == Mouse.left
x, y = mouseposition(ax.scene)
a,b = ceil(Int,x), ceil(Int,y)
img[a,b] += 1
img[a,b] = (img[a,b])%2
print(a,b)
image!(img,interpolate = false)
end
end
Few problems with this:
trunc doesnt work well, I need to implement square boxes. But I would appreciate if someone has better work around.I usedceil
and it works well. Though, misbehaves if clicked outside axis.The click event doesnt work.On clicking boxes, it momentarily changes and then again goes back to original form. I tracked how it changes the value of matrix img, and it seems that somehow multi-threading is causing the problem. I would like if someone gives insight on this. how to overcome this.