From 76e0502faf13dd8e188c815bb54834b910ce72db Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 11 May 2023 12:36:09 -0600 Subject: [PATCH] textPlate helper --- src/kiss_flixel/SpriteTools.kiss | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/kiss_flixel/SpriteTools.kiss b/src/kiss_flixel/SpriteTools.kiss index ff6f9eb..9f3e012 100644 --- a/src/kiss_flixel/SpriteTools.kiss +++ b/src/kiss_flixel/SpriteTools.kiss @@ -58,4 +58,16 @@ (let [bitmapData sprite.pixels &mut bytes (new ByteArray)] (set bytes (bitmapData.encode bitmapData.rect (new PNGEncoderOptions true) bytes)) - (File.saveBytes file bytes)))) \ No newline at end of file + (File.saveBytes file bytes)))) + +(function :FlxSprite textPlate [:String text :Int size :Int margin &opt :FlxColor textColor :FlxColor bgColor] + (unless textColor (set textColor FlxColor.WHITE)) + (unless bgColor (set bgColor FlxColor.BLACK)) + (let [flxText (new FlxText 0 0 0 text size) + textWidth flxText.width + textHeight flxText.height + plate (new FlxSprite)] + (set flxText.color textColor) + (plate.makeGraphic (+ (* 2 margin) textWidth) (+ (* 2 margin) textHeight) bgColor) + (plate.stamp flxText margin margin) + plate)) \ No newline at end of file