merged from master

This commit is contained in:
juliandescottes
2012-09-11 00:59:52 +02:00
28 changed files with 808 additions and 643 deletions

View File

@@ -8,6 +8,11 @@
};
ns.Frame.createEmpty = function (width, height) {
var pixels = ns.Frame.createEmptyPixelGrid_(width, height);
return new ns.Frame(pixels);
};
ns.Frame.createEmptyPixelGrid_ = function (width, height) {
var pixels = []; //new Array(width);
for (var columnIndex=0; columnIndex < width; columnIndex++) {
var columnArray = [];
@@ -16,7 +21,7 @@
}
pixels[columnIndex] = columnArray;
}
return new ns.Frame(pixels);
return pixels;
};
ns.Frame.createEmptyFromFrame = function (frame) {
@@ -41,6 +46,13 @@
this.pixels = this.clonePixels_(pixels);
};
ns.Frame.prototype.clear = function () {
var pixels = ns.Frame.createEmptyPixelGrid_(this.getWidth(), this.getHeight());
this.setPixels(pixels);
};
/**
* Clone a set of pixels. Should be static utility method
* @private
@@ -48,7 +60,7 @@
ns.Frame.prototype.clonePixels_ = function (pixels) {
var clonedPixels = [];
for (var col = 0 ; col < pixels.length ; col++) {
clonedPixels[col] = pixels[col].slice(0 , pixels[col].length-1);
clonedPixels[col] = pixels[col].slice(0 , pixels[col].length);
}
return clonedPixels;
};

View File

@@ -4,10 +4,7 @@
this.width = width;
this.height = height;
this.frames = [];
};
ns.FrameSheet.prototype.validate = function () {
throw "FrameSheet.prototype.validate not implemented"
this.currentFrameIndex = 0;
};
ns.FrameSheet.prototype.addEmptyFrame = function () {
@@ -22,6 +19,15 @@
return this.frames.length;
};
ns.FrameSheet.prototype.getCurrentFrame = function () {
return this.frames[this.currentFrameIndex];
};
ns.FrameSheet.prototype.setCurrentFrameIndex = function (index) {
this.currentFrameIndex = index;
$.publish(Events.FRAMESHEET_RESET);
};
ns.FrameSheet.prototype.getUsedColors = function() {
var colors = {};
for (var frameIndex=0; frameIndex < this.frames.length; frameIndex++) {