Source on github:
https://github.com/kawanet/as3kawalib/raw/master/src/net/kawa/display/KDrawSprite.as
Document:
http://www.kawa.net/works/as/as3kawalib/docs/net/kawa/display/KDrawSprite.html
KDrawSprite draws your vector image onto a bitmap image. You don't need to manipulate cacheAsBitmapMatrix and cacheAsBitmap properties. These are powerful, however, sometimes make our app crashed erratically. You need take more care for iPad which has larger screen but has less memory.
How To Use This
Simply call KDrawSprite.getSprite() instead of setting cacheAsBitmapMatrix and cacheAsBitmap properties.var sprite:Sprite = new Sprite();Bitmap operations such as moving, scaling and rotation will be GPU enabled.
sprite.graphics.beginFill(0x336699);
sprite.graphics.drawCircle(50, 50, 50);
// sprite.cacheAsBitmapMatrix = new Matrix(); // BEFORE
// sprite.cacheAsBitmap = true;
sprite = KDrawSprite.getSprite(sprite); // AFTER
addChild(sprite);
sprite.x = 100;
sprite.y = 100;
sprite.scaleX = 0.5;
sprite.height = 50;
sprite.rotation = 1;
KDrawSprite will also free memory of image rendered when it comes out of the Stage.
You need call getSprite() or draw() method whenever you make changes on the vector source image. This also means any other needless re-rendering will not be invoked. Learn more on document.
Super Sampling Anti-Aliasing (2x SSAA)
KDrawSprite supports 2x SSAA, super sampling anti-aliasing, in addition to NoAA per default.Note
To get better performance and rendering quality, you MUST set stage.quality as StageQuality.LOW. Also use 2x SSAA when needed.stage.quality = StageQuality.LOW; // must
* Japanese version of this post is here.