Canvas and Borders

howto

#1

888-1

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


#2

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.


#3

What am I doing wrong? Help! :thinking:


#4

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


#5

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).

Blocks:

Designer:
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!


#6

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!