#include <time.h>
#include <sys/time.h>
#include "internal.h"
Go to the source code of this file.
|
int | ncfadectx_iterations (const ncfadectx *nctx) |
|
int | ncplane_fadein_iteration (ncplane *n, ncfadectx *nctx, int iter, 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 | ncplane_fadeout (ncplane *n, const struct timespec *ts, fadecb fader, void *curry) |
|
int | ncplane_fadein (ncplane *n, const struct timespec *ts, fadecb fader, void *curry) |
|
int | ncplane_pulse (ncplane *n, const struct timespec *ts, fadecb fader, void *curry) |
|
◆ ncfadectx
◆ ncfadectx_free()
Definition at line 253 of file fade.c.
253 {
254 if(nctx){
257 }
258}
◆ ncfadectx_iterations()
int ncfadectx_iterations |
( |
const ncfadectx * |
nctx | ) |
|
◆ ncfadectx_setup()
Definition at line 249 of file fade.c.
249 {
250 return ncfadectx_setup_internal(
n,
NULL);
251}
◆ ncplane_fadein()
int ncplane_fadein |
( |
ncplane * |
n, |
|
|
const struct timespec * |
ts, |
|
|
fadecb |
fader, |
|
|
void * |
curry |
|
) |
| |
Definition at line 284 of file fade.c.
284 {
285 ncfadectx* nctx = ncfadectx_setup_internal(
n, ts);
287 struct timespec now;
288 clock_gettime(CLOCK_MONOTONIC, &now);
289 if(fader){
291 }else{
293 }
294 return -1;
295 }
296 int ret = ncplane_fadein_internal(
n, fader, nctx, curry);
298 return ret;
299}
void ncfadectx_free(ncfadectx *nctx)
notcurses * ncplane_notcurses(const ncplane *n)
◆ ncplane_fadein_iteration()
Definition at line 109 of file fade.c.
110 {
111
112
113 unsigned dimy, dimx;
116 for(
y = 0 ;
y < nctx->
rows &&
y < dimy ; ++
y){
117 for(
unsigned x = 0 ;
x < nctx->
cols &&
x < dimx; ++
x){
120 unsigned br, bg, bb;
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);
128 }
129 if(!nccell_bg_default_p(
c)){
133 nccell_set_bg_rgb8(
c, br, bg, bb);
134 }
135 }
136 }
138 struct timespec sleepspec;
139 sleepspec.tv_sec = nextwake / NANOSECS_IN_SEC;
140 sleepspec.tv_nsec = nextwake % NANOSECS_IN_SEC;
141 int ret = 0;
142 if(fader){
144 }else{
146
147
148 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleepspec,
NULL);
149 }
150 return ret;
151}
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
◆ ncplane_fadeout()
int ncplane_fadeout |
( |
ncplane * |
n, |
|
|
const struct timespec * |
ts, |
|
|
fadecb |
fader, |
|
|
void * |
curry |
|
) |
| |
Definition at line 260 of file fade.c.
260 {
261 ncfadectx* pp = ncfadectx_setup_internal(
n, ts);
262 if(!pp){
263 return -1;
264 }
265 struct timespec times;
266 ns_to_timespec(pp->
startns, ×);
267 do{
268 uint64_t curns = times.tv_sec * NANOSECS_IN_SEC + times.tv_nsec;
271 break;
272 }
277 }
278 clock_gettime(CLOCK_MONOTONIC, ×);
279 }while(true);
281 return 0;
282}
int ncplane_fadeout_iteration(ncplane *n, ncfadectx *nctx, int iter, fadecb fader, void *curry)
◆ ncplane_fadeout_iteration()
Definition at line 174 of file fade.c.
175 {
176 unsigned br, bg, bb;
178
179
180 unsigned dimy, dimx;
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);
192 }
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);
199 }
200 }
201 }
203 if(!nccell_fg_default_p(
c)){
208 nccell_set_fg_rgb8(&
n->basecell,
r, g, b);
209 }
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);
216 }
218 struct timespec sleepspec;
219 sleepspec.tv_sec = nextwake / NANOSECS_IN_SEC;
220 sleepspec.tv_nsec = nextwake % NANOSECS_IN_SEC;
221 int ret;
222 if(fader){
224 }else{
226
227
228 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleepspec,
NULL);
229 }
230 return ret;
231}
◆ ncplane_pulse()
int ncplane_pulse |
( |
ncplane * |
n, |
|
|
const struct timespec * |
ts, |
|
|
fadecb |
fader, |
|
|
void * |
curry |
|
) |
| |
Definition at line 301 of file fade.c.
301 {
303 int ret;
305 return -1;
306 }
307 if(alloc_ncplane_palette(
n, &pp, ts)){
308 return -1;
309 }
310 for(;;){
311 ret = ncplane_fadein_internal(
n, fader, &pp, curry);
312 if(ret){
313 break;
314 }
316 if(ret){
317 break;
318 }
319 }
321 return ret;
322}
int ncplane_fadeout(ncplane *n, const struct timespec *ts, fadecb fader, void *curry)