Skip to content

Instantly share code, notes, and snippets.

@gigafied
Created February 14, 2012 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigafied/1829852 to your computer and use it in GitHub Desktop.
Save gigafied/1829852 to your computer and use it in GitHub Desktop.
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