// category Image. Create using: new image(urlToImage) function image(url) { // image.subImages

The total number of subimages in the image. Defaults to 1. this.subImages = 1; // image.subImagesPerRow

The total number of subimages per row. Defaults to 1. this.subImagesPerRow = 1; $("body").append(''); this.g_image = $("#image")[0]; $("#image").attr("id",""); // image.draw(subImg, x, y, w, h, rotation)

Draw an image at (x,y), size (w,h), at an angle in degrees. this.draw = function(subImg, x, y, w, h, rotation) { subImg %= this.subImages; var context = GameWindow.canvasContext; context.save(); context.translate(x, y); context.rotate(rotation * (Math.PI/180)); var c = subImg % this.subImagesPerRow; var r = Math.ceil(subImg / this.subImagesPerRow); var sw = (this.g_image.width / this.subImagesPerRow); var sh = (this.g_image.height / Math.ceil(this.subImages / this.subImagesPerRow)); var sx = sw * c; var sy = sh * r; context.drawImage(this.g_image, sx, sy, sw, sh, -w/2, -h/2, w, h); context.restore(); } }