/** @language english
* Initializes a LBitmap object to refer to the specified LBitmapData object.
* The LBitmap class represents display objects that represent bitmap images. These can be images that you load with the LLoader class, or they can be images that you create with the LBitmap() constructor.
* The LBitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. After you create a LBitmap object, use the addChild() or addChildAt() method of the parent instance to place the bitmap on the display list.
* A LBitmap object can share its BitmapData reference among several Bitmap objects, independent of translation or rotation properties. Because you can create multiple LBitmap objects that reference the same BitmapData object, multiple display objects can use the same complex BitmapData object without incurring the memory overhead of a BitmapData object for each display object instance.
* A LBitmapData object can be drawn to the screen by a LBitmap object in one of two ways: by using the vector renderer as a fill-bitmap shape, or by using a faster pixel-copying routine. The pixel-copying routine is substantially faster than the vector renderer.
* The LBitmap class is not a subclass of the InteractiveObject class, so it cannot dispatch mouse events. However, you can use the addEventListener() method of the display object container that contains the LBitmap object.
* @class LBitmap
* @extends LDisplayObject
* @constructor
* @param {LBitmapData} bitmapData The LBitmapData object being referenced.
* @example
* Linit(50, "mylegend", 800, 480, main);
* function main () {
* var loader = new LLoader();
* loader.addEventListener(LEvent.COMPLETE, loadBitmapdata);
* loader.load("lufylegend.js.png", "bitmapData");
* }
* function loadBitmapdata (event) {
* var bitmapdata = new LBitmapData(event.currentTarget);
* var bitmap = new LBitmap(bitmapdata);
* addChild(bitmap);
* }
* @examplelink <p><a href="../../../api/LBitmap/index.html" target="_blank">Try it »</a></p>
* @since 1.0.0
* @public
*/
var LBitmap = (function () {
function LBitmap (bitmapdata) {
var s = this;
LExtends(s, LDisplayObject, []);
/** @language english
* type of the object
* @property type
* @type String
* @default LBitmap
* @since 1.0.0
* @public
*/
s.type = "LBitmap";
/** @language english
* Set the LBitmap object's center of rotation .
* @property rotateCenter
* @type Boolean
* @default true
* @since 1.8.0
* @public
*/
s.rotateCenter = true;
/** @language english
* The LBitmapData object being referenced.
* @property bitmapData
* @type LBitmapData
* @default true
* @since 1.0.0
* @public
*/
s.bitmapData = bitmapdata;
if (s.bitmapData) {
s.width = s.bitmapData.width;
s.height = s.bitmapData.height;
}
}
var p = {
_canShow : function () {
return (this.visible && this.bitmapData);
},
_rotateReady : function () {
var s = this;
if (s.rotate != 0 && s.rotateCenter) {
s.rotatex = s.getWidth() * 0.5;
s.rotatey = s.getHeight() * 0.5;
} else {
s.rotatex = s.rotatey = 0;
}
},
_coordinate : function (c) {},
_ll_show : function () {
this.ll_draw();
},
ll_draw : function () {
var s = this;
LGlobal.canvas.drawImage(s.bitmapData.image,
s.bitmapData.x,
s.bitmapData.y,
s.bitmapData.width,
s.bitmapData.height,
s.x,
s.y,
s.bitmapData.width,
s.bitmapData.height
);
},
/** @language english
* Returns a new LBitmap object that is a clone of the original instance with an exact copy of the contained bitmap.
* @method clone
* @return {LBitmap} A new LSprite object that is identical to the original.
* @since 1.8.2
* @public
* @example
* var bmd = new LBitmapData("#FF0000", 0, 0, 100, 100);
* var bm1 = new LBitmap(bmd);
* addChild(bm1);
*
* var bm2 = bm1.clone();
* bm2.x = 120;
* addChild(bm2);
* @examplelink <p><a href="../../../api/LBitmap/clone.html" target="_blank">Try it »</a></p>
*/
clone : function () {
var s = this, a = new LBitmap(s.bitmapData.clone());
a.copyProperty(s);
a.rotateCenter = s.rotateCenter;
return a;
},
ismouseon : function (e, cood) {
var s = this;
if (!e) {
return false;
}
if (!s.visible || !s.bitmapData) {
return false;
}
if (s.mask) {
if (!s.mask.parent) {
s.mask.parent = s.parent;
}
if (!s.mask.ismouseon(e, cood)) {
return false;
}
}
return s.ismouseonShapes([{type : LShape.RECT, arg : [0, 0, s.bitmapData.width, s.bitmapData.height]}], e.offsetX, e.offsetY);
},
/** @language english
* Get the width of the display object, in pixels.
* @method getWidth
* @return {float} the width of the display object.
* @since 1.0.0
* @public
* @example
* var bitmapdata = new LBitmapData(event.currentTarget);
* var bitmap = new LBitmap(bitmapdata);
* addChild(bitmap);
* trace("width : " + bitmap.getWidth());
* @examplelink <p><a href="../../../api/LBitmap/getWidth.html" target="_blank">Try it »</a></p>
*/
getWidth : function (maskSize) {
var s = this, w, mx, mw;
w = s.bitmapData != null ? s.bitmapData.width * (s.scaleX > 0 ? s.scaleX : -s.scaleX) : 0;
if (maskSize && s.mask) {
mx = s.mask._startX ? s.mask._startX() : s.mask.startX();
if (mx > w) {
return 0;
}
mw = s.mask.getWidth();
if (mx + mw > w) {
return w - mx;
}else{
return mw;
}
}
return w;
},
/** @language english
* Get the height of the display object, in pixels.
* @method getHeight
* @return {float} the height of the display object.
* @since 1.0.0
* @public
* @example
* var bitmapdata = new LBitmapData(event.currentTarget);
* var bitmap = new LBitmap(bitmapdata);
* addChild(bitmap);
* trace("height : " + bitmap.getHeight());
* @examplelink <p><a href="../../../api/LBitmap/getHeight.html" target="_blank">Try it »</a></p>
*/
getHeight : function (maskSize) {
var s = this, h, my, mh;
h = s.bitmapData != null ? s.bitmapData.height * (s.scaleY > 0 ? s.scaleY : -s.scaleY) : 0;
if (maskSize && s.mask) {
my = s.mask._startY ? s.mask._startY() : s.mask.startY();
if (my > h) {
return 0;
}
mh = s.mask.getHeight();
if (my + mh > h) {
return h - my;
}else{
return mh;
}
}
return h;
},
startX : function () {
return this.x;
},
startY : function () {
return this.y;
},
die : function () {}
};
for (var k in p) {
LBitmap.prototype[k] = p[k];
}
return LBitmap;
})();
/** @language english
* Disabled.
* @event LEvent.ENTER_FRAME
*/