33 unsigned r, g, b, br, bg, bb;
36 for(
y = 0 ;
y < pp->
rows ; ++
y){
37 for(
unsigned x = 0 ;
x < pp->
cols ; ++
x){
38 channels =
n->fb[nfbcellidx(
n,
y,
x)].channels;
40 ncchannels_fg_rgb8(channels, &
r, &g, &b);
50 ncchannels_bg_rgb8(channels, &br, &bg, &bb);
62 channels =
n->basecell.channels;
64 ncchannels_fg_rgb8(channels, &
r, &g, &b);
74 ncchannels_bg_rgb8(channels, &br, &bg, &bb);
85 (pp->maxb > pp->maxr ? pp->maxb : pp->maxr);
87 (pp->maxbb > pp->maxbr ? pp->maxbb : pp->maxbr);
88 pp->
maxsteps = maxfsteps > maxbsteps ? maxfsteps : maxbsteps;
92 uint64_t nanosecs_total;
94 nanosecs_total = timespec_to_ns(ts);
102 struct timespec times;
103 clock_gettime(CLOCK_MONOTONIC, ×);
105 pp->
startns = timespec_to_ns(×);
110 fadecb fader,
void* curry){
116 for(
y = 0 ;
y < nctx->
rows &&
y < dimy ; ++
y){
117 for(
unsigned x = 0 ;
x < nctx->
cols &&
x < dimx; ++
x){
121 ncchannels_bg_rgb8(nctx->
channels[nctx->
cols *
y +
x], &br, &bg, &bb);
123 if(!nccell_fg_default_p(
c)){
127 nccell_set_fg_rgb8(
c,
r, g, b);
129 if(!nccell_bg_default_p(
c)){
133 nccell_set_bg_rgb8(
c, br, bg, bb);
138 struct timespec sleepspec;
139 sleepspec.tv_sec = nextwake / NANOSECS_IN_SEC;
140 sleepspec.tv_nsec = nextwake % NANOSECS_IN_SEC;
148 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleepspec,
NULL);
158 struct timespec times;
159 clock_gettime(CLOCK_MONOTONIC, ×);
160 curns = times.tv_sec * NANOSECS_IN_SEC + times.tv_nsec;
169 clock_gettime(CLOCK_MONOTONIC, ×);
175 fadecb fader,
void* curry){
183 for(
y = 0 ;
y < nctx->
rows &&
y < dimy ; ++
y){
184 for(
unsigned x = 0 ;
x < nctx->
cols &&
x < dimx; ++
x){
186 if(!nccell_fg_default_p(
c)){
191 nccell_set_fg_rgb8(
c,
r, g, b);
193 if(!nccell_bg_default_p(
c)){
194 ncchannels_bg_rgb8(nctx->
channels[nctx->
cols *
y +
x], &br, &bg, &bb);
198 nccell_set_bg_rgb8(
c, br, bg, bb);
203 if(!nccell_fg_default_p(
c)){
208 nccell_set_fg_rgb8(&
n->basecell,
r, g, b);
210 if(!nccell_bg_default_p(
c)){
211 ncchannels_bg_rgb8(nctx->
channels[nctx->
cols *
y], &br, &bg, &bb);
215 nccell_set_bg_rgb8(&
n->basecell, br, bg, bb);
218 struct timespec sleepspec;
219 sleepspec.tv_sec = nextwake / NANOSECS_IN_SEC;
220 sleepspec.tv_nsec = nextwake % NANOSECS_IN_SEC;
228 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleepspec,
NULL);
234ncfadectx_setup_internal(
ncplane*
n,
const struct timespec* ts){
241 if(alloc_ncplane_palette(
n, nctx, ts) == 0){
250 return ncfadectx_setup_internal(
n,
NULL);
261 ncfadectx* pp = ncfadectx_setup_internal(
n, ts);
265 struct timespec times;
266 ns_to_timespec(pp->
startns, ×);
268 uint64_t curns = times.tv_sec * NANOSECS_IN_SEC + times.tv_nsec;
278 clock_gettime(CLOCK_MONOTONIC, ×);
285 ncfadectx* nctx = ncfadectx_setup_internal(
n, ts);
288 clock_gettime(CLOCK_MONOTONIC, &now);
296 int ret = ncplane_fadein_internal(
n, fader, nctx, curry);
307 if(alloc_ncplane_palette(
n, &pp, ts)){
311 ret = ncplane_fadein_internal(
n, fader, &pp, curry);
int ncplane_pulse(ncplane *n, const struct timespec *ts, fadecb fader, void *curry)
int ncplane_fadeout(ncplane *n, const struct timespec *ts, fadecb fader, void *curry)
int ncplane_fadein_iteration(ncplane *n, ncfadectx *nctx, int iter, fadecb fader, void *curry)
int ncplane_fadein(ncplane *n, const struct timespec *ts, fadecb fader, void *curry)
int ncplane_fadeout_iteration(ncplane *n, ncfadectx *nctx, int iter, fadecb fader, void *curry)
ncfadectx * ncfadectx_setup(ncplane *n)
void ncfadectx_free(ncfadectx *nctx)
int ncfadectx_iterations(const ncfadectx *nctx)
notcurses * ncplane_notcurses(const ncplane *n)
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
int(* fadecb)(struct notcurses *nc, struct ncplane *n, const struct timespec *, void *curry)