notcurses_fade - fade ncplanes in and out
Contents
Bugs
Palette reprogramming can affect other contents of the terminal in complex ways. This is not a problem
when the RGB method is used.
Description
ncplane_fadeout, ncplane_fadein, and ncplane_pulse are simple APIs for fading planes in and out. Fades
require either RGB support or palette reprogramming support from the terminal (the RGB method is preβ
ferred, and will be used whenever possible). The ts parameter specifies the total amount of time for the
fade operation. The operation itself is time-adaptive (i.e. if it finds itself falling behind, it will
skip iterations; if it is proceeding too quickly, it will sleep).
These are wrappers around the more flexible ncfadectx API. Create an ncfadectx with ncfadectx_setup.
The number of possible state changes (iterations) can be accessed with ncfadectx_iterations. A state can
be reached with ncplane_fadeout_iteration or ncplane_fadein_iteration. Finally, destroy the ncfadectx
with ncfadectx_free.
Name
notcurses_fade - fade ncplanes in and out
Return Values
ncplane_fadeout_iteration and ncplane_fadein_iteration will propagate out any non-zero return value from
the callback fader.
See Also
clock_nanosleep(2), notcurses(3), notcurses_plane(3)
Synopsis
#include<notcurses/notcurses.h>
struct ncfadectx;
// Called for each delta performed in a fade on ncp. If anything but 0 is
// returned, the fading operation ceases immediately, and that value is
// propagated out. If provided and not NULL, the faders will not themselves
// call notcurses_render().
typedef int (*fadecb)(struct notcurses* nc, struct ncplane* ncp,
const struct timespec*, void* curry);
boolnotcurses_canfade(conststructnotcurses*nc);intncplane_fadeout(structncplane*n,conststructtimespec*ts,fadecbfader,void*curry);intncplane_fadein(structncplane*n,conststructtimespec*ts,fadecbfader,void*curry);intncplane_pulse(structncplane*n,conststructtimespec*ts,fadecbfader,void*curry);structncfadectx*ncfadectx_setup(structncplane*n);intncfadectx_iterations(conststructncfadectx*nctx);intncplane_fadeout_iteration(structncplane*n,structncfadectx*nctx,intiter,fadecbfader,void*curry);intncplane_fadein_iteration(structncplane*n,structncfadectx*nctx,intiter,fadecbfader,void*curry);voidncfadectx_free(structncfadectx*nctx);