Help needed to copy part of a canvas

I change the width of the line and this way DrawPoint does draw a small square, not just a pixel.

I will look at that extension.

Yes, for the moment I discard the part that moves out of the screen.

Not tested:

save canvas then set it as background image, will make the image more and more blur.
Maybe try to set background image with Base64, using this extension.

I will try, but the problem is not in which format the image is stored. I can store it as a png, which is a lossless compression. The problem is that the background image is not stored at the resolution of the canvas, so in the storing process itself data is lost.

Since all your pattern is drawn by DrawPoint, you can save all the point location (x,y), to a list. When redraw, loop on this list, draw the point at (x+offsetX, y+offsetY), save this new location also.
Also add the new drawn point to this list.

1 Like

I propose separating the grid calculations from its rendering.

This procedure should emit a table (list of lists) of 1s and 0s for a grid to be fed to a rendering procedure.

Because the grid repeats, it need only be computed once.

The SVG rendering of each row also needs to be done only once.

Linked lists are perfect for cycling through rows of tables.