Hello!
I wrote a Flashpunk extension: Scale9Image
available as gist.
Scale9Image
is an extended Image
.
Constructor:
-
Scale9Image(source:*, scale9Grid:Rectangle, clipRect:Rectangle = null, W:int = -1, H:int = -1, disposeRegions:Boolean = true)
-
source
-BitmapData
orClass
same as normalImage
-
scale9Grid
-Rectangle
-> Scale 9 grid -
clipRect
-Rectangle
-
W
-int
->Image width
-
H
-int
->Image height
-
disposeRegions
-Boolean
-> If regions should dispose after creating the image, if you plan toredraw
it to another size later or often, I recommend to disable it.
How to use:
-
For example you have a 13x13 scale 9 / slice 9 button image as
ButtonBitmapData
: -
var buttonImage:Scale9Image = new Scale9Image(ButtonBitmapData, new Rectangle(6, 6, 1, 1), null, 100, 20, true);
-
This code will create a 100x20
Image
out of 13x13BitmapData
with 6x6 each border and 1x1 pattern-scaling pixel.
Please reply a feedback.