2013-09-22 19:02:43 +00:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace('pskl.utils');
|
|
|
|
|
|
|
|
ns.FrameUtils = {
|
|
|
|
merge : function (frames) {
|
2013-09-26 05:47:11 +00:00
|
|
|
var merged = null;
|
|
|
|
if (frames.length) {
|
|
|
|
merged = frames[0].clone();
|
|
|
|
var w = merged.getWidth(), h = merged.getHeight();
|
|
|
|
for (var i = 1 ; i < frames.length ; i++) {
|
|
|
|
pskl.utils.FrameUtils.mergeFrames_(merged, frames[i]);
|
|
|
|
}
|
2013-09-22 19:02:43 +00:00
|
|
|
}
|
|
|
|
return merged;
|
|
|
|
},
|
|
|
|
|
|
|
|
mergeFrames_ : function (frameA, frameB) {
|
|
|
|
frameB.forEachPixel(function (p, col, row) {
|
|
|
|
if (p != Constants.TRANSPARENT_COLOR) {
|
|
|
|
frameA.setPixel(col, row, p);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|