Canvas and Borders




How to specify canvas borders so that the line does not go beyond the border?


You can use an IF block while dragging to check if the x,y pixel about to be painted is white or not. If it’s not, don’t draw on it.

Another solution will be to make the border a sprite, with a “hollow” center (png) and since a sprite is always on top of any drawing on the canvas, it will never be covered by the drawing.

A more complex solution would be to make the whole thing a layout of one arrangement with the frame as the background image, then the canvas in the middle of that arrangement, but this will have to be more precise because of the many screen sizes available.


What am I doing wrong? Help! :thinking:


We don’t know. What do you want to do and and what’s the result of that?


Never tried this but I made it to show you and because I got curious about it :grin:
And it works fine. I suggest you use this solution (sprite).


You will need a canvas, a sprite set at x=0, y=0

Then the app on start up will resize the sprite to whatever the canvas size is and that’s it! Happy drawing!


Thank You! Why didn’t I think of that? No wonder they say that one head is good, and two are better… I will follow Your advice… Thanks again!