Skip to content

Instantly share code, notes, and snippets.

@valexa
Last active December 12, 2015 04:18
Show Gist options
  • Save valexa/4713351 to your computer and use it in GitHub Desktop.
Save valexa/4713351 to your computer and use it in GitHub Desktop.
float lastTick = 0.0;
for (int i = 0; i <= 900; i++) {
float t = [self tickX:9 timesOfTotal:900 current:i lastTick:lastTick];
if (t > 0) {
NSLog(@"%f %i",t,i);
lastTick = t;
}
}
-(float)tickX:(int)times
timesOfTotal:(float)total
current:(float)current
lastTick:(float)last
{
float tickUnit = 1.0 / times;
float ret = last + tickUnit;
float oneUnit = total / times;
float nextTick = ret * (times) * oneUnit;
if (current == 0) return 0.000001;
if (current >= total) return 1.0;
if (current > nextTick)
{
return ret;
}else{
return 0.0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment