Skip to content

Instantly share code, notes, and snippets.

@molant
Created March 10, 2013 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molant/5127080 to your computer and use it in GitHub Desktop.
Save molant/5127080 to your computer and use it in GitHub Desktop.
Game Loop example for video editing project
function tick(){
//we clean if we've changed the size of the quadrant
if(needsClean){
cleanCanvas();
}
//if we have to change the quadrant's frame because we are the active one (or the opposite)
if(newFrame){
drawFrame(); //we draw just the frame in a separate canvas so it doesn't need to be calculated all the time, and it is still faster than copying from an image
}
//we draw the new frame if we are playing or seeking
if(dirty){
draw();
drawFrameInQuadrant();
}
requestAnimationFrame(tick);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment