Change timeout-based animation to tick-based animation, corrects canvas clear bug.