Created
June 13, 2016 09:31
-
-
Save rubeniskov/d4628dcb6dbc658d9bed84a594bb3270 to your computer and use it in GitHub Desktop.
Frame Split Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var video = (new Array(100).join(',').split(',').map(function(v,i){return i})), | |
sprite = function(start, length, split) { | |
split = split != null ? split : 5; | |
start = start != null ? start : 0; | |
length = length != null ? start + length : undefined; | |
var r = [], | |
frames = video.slice(start, length); | |
for (var i = 0; i < frames.length; i++) | |
frames[i] % split === 0 && r.push(frames[i]); | |
return r; | |
}; | |
sprite(); // [5, 10] | |
sprite(5); // [5, 10] | |
sprite(5, 5); // [5, 10] | |
sprite(5, 5, 5); // [5, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment