Converting a text into an image

Hello, I need to assign a text in a Sprite, so that the user can freely move the Sprite around the canvas and I can take advantage of the rich range of events that a Sprite offers (touch down, drag, etc.).

This is much more powerful if we compare with what a Label can offer. However, you can assign text to a Label, but Sprites do not support it.

I found a very good solution on the following page, but when I tried it, I found out that it does not work exactly as the author explains. I think the problem is that when the Canvas is not visible, the text that you draw in it is lost. It only works if you set visible=true, but in this case, you need to dedicate some space to the canvas and it is difficult if your UI is full of other graphical components:

https://groups.google.com/forum/#!msg/app-inventor-developers-library/4gYAOd1we-g/TxwQKodaKJUJ

Do you know if there exists a different way to create a visible canvas that will not interfere with the existing UI? May be opening the canvas in a new window? I am not sure if this will cause some strange flicking.

Thank you

You could try the Component 2 Image extension ?

It is a great idea!

Do you know if it will work using a hidden canvas? Currently I am having trouble because of that.

Thank you

The canvas will have to be visible, and of a size to suit the text.

You could try putting it below everything else on the screen so that it is visible but out of sight - if that makes senseā€¦

I did a little trick once, to be able to draw things in a hidden canvas and save the picture, and it worked.
The trick is to make a horizontal arrangement and make it fill parent on its width.
Then Inside it put an arrangement to the left and a canvas to the right. The arrangement on the left should have width 100% (not fill parent). That will push the canvas outside the screen, but will still count as visible.

2 Likes

thumbsup2

1 Like

@Italo, I just wanted to confirm that I have used the solution you proposed and it has worked very well. What a fantastic trick!

Thank you

1 Like

(added to FAQ)

1 Like