fade: throw a 10ms cap in, improves visual and lessens load

This commit is contained in:
nick black 2019-12-27 10:41:49 -05:00
parent 148114c6ca
commit d4caefc55d
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 9 additions and 1 deletions

View File

@ -173,7 +173,7 @@ int unicodeblocks_demo(struct notcurses* nc){
// we don't want a full delay period for each one, urk...or do we?
struct timespec subdelay;
uint64_t nstotal = timespec_to_ns(&demodelay);
ns_to_timespec(nstotal / 5, &subdelay);
ns_to_timespec(nstotal / 3, &subdelay);
for(sindex = 0 ; sindex < sizeof(blocks) / sizeof(*blocks) ; ++sindex){
ncplane_set_bg_rgb(n, 0, 0, 0);
//ncplane_erase(n);

View File

@ -99,6 +99,10 @@ int ncplane_fadein(ncplane* n, const struct timespec* ts, fadecb fader){
int maxsteps = maxfsteps > maxbsteps ? maxfsteps : maxbsteps;
uint64_t nanosecs_total = ts->tv_sec * NANOSECS_IN_SEC + ts->tv_nsec;
uint64_t nanosecs_step = nanosecs_total / maxsteps;
while(nanosecs_step < 10000000){ // 10msec
nanosecs_step *= 10;
maxsteps = nanosecs_total / nanosecs_step;
}
struct timespec times;
clock_gettime(CLOCK_MONOTONIC, &times);
// Start time in absolute nanoseconds
@ -174,6 +178,10 @@ int ncplane_fadeout(struct ncplane* n, const struct timespec* ts, fadecb fader){
int maxsteps = maxfsteps > maxbsteps ? maxfsteps : maxbsteps;
uint64_t nanosecs_total = ts->tv_sec * NANOSECS_IN_SEC + ts->tv_nsec;
uint64_t nanosecs_step = nanosecs_total / maxsteps;
while(nanosecs_step < 10000000){ // 10msec
nanosecs_step *= 10;
maxsteps = nanosecs_total / nanosecs_step;
}
struct timespec times;
clock_gettime(CLOCK_MONOTONIC, &times);
// Start time in absolute nanoseconds