Hi
How do I render text as bitmap on the screen? I have TextField at the moment and it works fine but I would like it to be bitmap or vector data on the screen. What are my options? Any basic samples?
thanks
Hi
How do I render text as bitmap on the screen? I have TextField at the moment and it works fine but I would like it to be bitmap or vector data on the screen. What are my options? Any basic samples?
thanks
var textField = new openfl.text.TextField();
// all your stuff on the textField
var textFieldBitmapData = new openfl.display.BitmapData(textField.width, textField.height, true, 0x000000);
textFieldBitmapData.draw(textField);
var textFieldBitmap = new openfl.display.Bitmap(textFieldBitmapData);
textFieldBitmap.smoothing = true;
Lib.current.stage.addChild(textFieldBitmap);
easy
basically it’s all about drawing the TextField on the BitmapData
then you do what you want
(remember SMOOTHING, otherwise it will look pretty bad)
That is more than awesome, it is as easy as writing directly to Sprite memory on C64.
And how do I clean the bitmap if I were to draw something else on it?
thanks
//clear bitmap
textFieldBitmapData.fillRect(new Rectangle(0,0,textFieldBitmapData.width,textFieldBitmapData.height), 0x00000000)
notice the color, it is an ARGB!
the “complete” function (which I use it to redraw a Text everytime it changes onto the same bitmapData) is here.