fix : reduce piskel model size : ImportController

+ ImportController is no longer relying on the deserializer to build a
  piskel instance
+ Static builders have been added to Piskel and Layer to help easily
  create new instances from existing elements
This commit is contained in:
jdescottes
2013-11-14 23:03:29 +01:00
parent e9a2ccfd1d
commit 4a1a7b6c2b
7 changed files with 228 additions and 59 deletions

View File

@ -153,15 +153,12 @@
var image = pskl.utils.ImageResizer.resize(this.importedImage_, w, h, smoothing);
var frame = pskl.utils.FrameUtils.createFromImage(image);
// TODO : juliandescottes : here we only want to create a layer from an array of frames, and create a new piskel using this layer
// we shouldn't use the deserializer for this ... it's only working because it's falling back to the old implementation
// bad, very bad
var deserializer = new pskl.utils.Deserializer([frame], function (piskel) {
pskl.app.piskelController.setPiskel(piskel);
pskl.app.animationController.setFPS(Constants.DEFAULT.FPS);
this.reset_();
}.bind(this));
deserializer.deserialize();
var layer = pskl.model.Layer.fromFrames('Layer 1', [frame]);
var piskel = pskl.model.Piskel.fromLayers([layer]);
pskl.app.piskelController.setPiskel(piskel);
pskl.app.animationController.setFPS(Constants.DEFAULT.FPS);
this.reset_();
}
}
};