I am also toying the idea that it might be possible to draw an entire row of the canvas as a single polygon shaped like a linear string of square beads, irregularly spaced.
But I have not yet figured out how you map your two matrixes into rows and columns.
I am doing it square by square. It takes a few seconds, so it is not that bad, but it would be better to have an almost instantaneous change. I guess, I will have to learn to create a dedicated extension.
I was also looking at the TaifunImage extension, but it is also problematic for me. There, too, the size of an image depends on where it loads it to, not how it is stored (or at least I could not yet figure out a way of forcing the size). That extension has a crop tool, which I could use to crop the image of the sprite before I place it on the canvas.
I also looked into the canvasLayer extension (it has a tool to copy part of a canvas to another layer), but I could not find a documentation for it , so it will take some time to figure out what part I need (it has a lot of tools).
To be honest, I am a bit surprised that there is no bitmap handling for images. That is how images are stored, it is a 2D array, it would be easy to manipulate that array to do the shift.
I have not thought about the webview. This is an interesting idea. SVG is indeed an option (if you could find your experiment, I would be interested to see it) or I can also try to use javascript to generate the image.
Unfortunately none of my android devices could show the svg, but I get the idea. I will be busy teaching during the week, but I will try something in the evenings. Thanks for your help.
As for my previous post about the positioning of the sprite on the screen, is it the intended behaviour to try to fit it in the screen, or is it a bug? If it is not the intended behaviour, how do I report it?
In order to be able to answer some of your questions. we could probably do with a simple example aia project: two canvases, one with a static background image, and your image capture method, along with then displaying the captured image in the second canvas?
I do have a simple example in post 20 of this thread that shows my problem with the positioning and sizing of sprites. I do not have two canvases there, but I do have a drawing in a canvas, saving that canvas, loading it back as a sprite and putting it on the canvas. I also explain my observations and problems in that post.
I added code to force the sprite size in proportion to the Canvas size, using pixel math.
I had to add colors to make the sprite more visible in contrast to the Canvas.
I am seeing bugs galore in AI2:
Canvas hops out of its Arrangement after a Canvas Save File
Sprite can't be dragged past edges, in spite of turning on the Canvas flag allowing edge escape.
The canvas image being saved is 535x535 pixels (not 200x200)
The canvas can receive a larger image and fit it to the canvas size, but an imageSprite with height and width set to automatic will return the 535x535 image.
There is also a bug with the canvas that moves it around, which also causes some confusion.
If you set the imageSprite height and width to 200x200, then the imageSprite will be the same size as the canvas, and will display as such.
What you cannot do is then move the imageSprite by 100x/100y, because it fills the canvas, and cannot go outside its bounds.
What you can do (not withstanding the implications of the aforementioned canvas bug), is have a fixed width and height arrangement (e.g. 200x200), centred both ways, and place a canvas of larger dimensions inside it (e.g. 800x800), then you can position an imageSprite of 200x200 outside of the "view" or anywhere in the view (the arrangement)
On my system the image is 400x400pixel, not 535x535. Apparently, this is system dependent and I don't quite understand how it is calculated. Why is it not the size of the canvas (which is fixed to 200x200)?
Resizing all the time is not really an option for me, because it will probably blur the edges (I will try though). To start with, a 100x100 filled black square on the top left corner of a 200x200 white canvas will not be saved in a 535x535 image as a black square on a white background with side length that is exactly half the length of the image, since half of 535 is not a whole number. Some interpolation will need to be used (which would be unnecessary if the size of the canvas would be kept).
Thanks for all your help, I will explore the different options. It will be slow though, because I will only have time to do this in the evenings.
In short: I would like to move the content of the canvas up or down by a fixed amount of pixels when a button is pressed.
A more detailed description:
I am drawing a pattern on the canvas, which includes rows of squares. The squares have fixed height. When the user presses a button, these rows needs to be shifted up or down by one row (and a new row needs to appear on the screen). The pattern is given by two lists. One list contains lists of 0,1 sequences, which describe the patterns in each row. The other list shows the order in which the rows of this pattern row list need to be displayed. I also include periodicity in the display, since the length of these lists are not the same as the length and width of the canvas (so I loop around).
At the moment I do a double loop (for the x and y direction) and call drawPoint several times to draw the squares individually. This is quite slow.
I was hoping that with a shift of the canvas image I can get rid of the double loop and draw only the new line.
you need to improve your drawPattern function, which use drawPoint pixel by pixel, that's too slow, you need to change to use DrawLine to draw small square.
You can move imageSprite out of canvas by using extension in post #40.
what about the part you move out of the canvas? just discard them?
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.