"Draw" image on a canvas


Currently we can set an image as the background of a canvas or use a sprite to place it in front of the background.
But I think there should be a method to “draw” an image file on the canvas without setting it as the background and without having to use a sprite for this.
The reason is because, if I use a sprite, I can’t draw text, points, lines or circles in front of it. The sprite is always in front of any drawn pixel.
And if I set it as a background, I can’t edit part of that image, leaving the background intact.
If I do a Canvas.clear, the image will be erased from the canvas, leaving the background color or image alone.
If I draw on top with transparent color, the background will show, exactly as it happens now with anything we draw on a canvas.

All this method should do is to change the required pixels to the image file pixels and leave the background property as it is. Just like if I draw a line, or a circle on a canvas, except that in this case is many pixels values taken from a file or asset.

Ideally the block should be something like this:


Is this something possible either with an extension or adding it to the Canvas component?


So that would save space because you have only to change a part of the screen instead of the whole screen?


@Italo trying to understand. You need to draw text on sprite?


No, just “place” an image on the canvas, without setting it as the background and without using a sprite.
Kind of like a “stamp”, for easier understanding.


I don’t know about the memory requirements of this method. It would be just like drawing a rectangle, which is filled with an image from a file.


This way you could build the screen up from blocks.


Probably, yes. I didn’t think of that use, but it’s one of the possibilities for sure.