Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
EaselJS - Bitmap class sample
minion.define("easel.display", {
Bitmap : minion.extend("easel.DisplayObject", {
image: null,
snapToPixel: true,
init : function (imageOrUri) {
this.__super(imageOrUri);
if (typeof imageOrUri == "string") {
this.image = new Image();
this.image.src = imageOrUri;
}
else {
this.image = imageOrUri;
}
},
isVisible : function () {
return this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && this.image && (this.image.complete || this.image.getContext || this.image.readyState >= 2);
},
draw : function (ctx, ignoreCache) {
if (this.__super(ctx, ignoreCache)) {
return true;
}
ctx.drawImage(this.image, 0, 0);
return true;
},
clone : function () {
var o = new Bitmap(this.image);
this.cloneProps(o);
return o;
},
toString : function () {
return "[Bitmap (name="+ this.name +")]";
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.