2013-09-22 23:02:43 +04:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace('pskl.utils');
|
|
|
|
|
|
|
|
ns.FrameUtils = {
|
|
|
|
merge : function (frames) {
|
2013-09-26 09:47:11 +04: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 23:02:43 +04:00
|
|
|
}
|
|
|
|
return merged;
|
|
|
|
},
|
|
|
|
|
|
|
|
mergeFrames_ : function (frameA, frameB) {
|
|
|
|
frameB.forEachPixel(function (p, col, row) {
|
|
|
|
if (p != Constants.TRANSPARENT_COLOR) {
|
|
|
|
frameA.setPixel(col, row, p);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|