piskel/js/utils/FrameUtils.js

25 lines
639 B
JavaScript
Raw Normal View History

(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]);
}
}
return merged;
},
mergeFrames_ : function (frameA, frameB) {
frameB.forEachPixel(function (p, col, row) {
if (p != Constants.TRANSPARENT_COLOR) {
frameA.setPixel(col, row, p);
}
});
}
};
})();