|
|
|
#include "demo.h"
|
|
|
|
|
|
|
|
// FIXME turn this into one large plane and move the plane, ratrher than
|
|
|
|
// manually redrawing each time
|
|
|
|
static const char* leg[] = {
|
|
|
|
" 88 88 88 88 88 88 88 ",
|
|
|
|
" \"\" 88 88 88 88 \"\" \"\" ,d ",
|
|
|
|
" 88 88 88 88 88 ",
|
|
|
|
" ,adPPYYba, 8b,dPPYba, 88 ,adPPYba, 88 ,d8 88,dPPYba, 88 ,adPPYYba, ,adPPYba, 88 ,d8 88 ,adPPYba, 88 8b,dPPYba, MM88MMM ",
|
|
|
|
" \"\" `Y8 88P' `\"8a 88 a8\" \"\" 88 ,a8\" 88P' \"8a 88 \"\" `Y8 a8\" \"\" 88 ,a8\" 88 a8\" \"8a 88 88P' `\"8a 88 ",
|
|
|
|
" ,adPPPPP88 88 88 88 8b 8888[ 88 d8 88 ,adPPPPP88 8b 8888[ 88 8b d8 88 88 88 88 ",
|
|
|
|
" 88, ,88 88 88 88 \"8a, ,aa 88`\"Yba, 88b, ,a8\" 88 88, ,88 \"8a, ,aa 88`\"Yba, 88 \"8a, ,a8\" 88 88 88 88, ",
|
|
|
|
" `\"8bbdP\"Y8 88 88 88 `\"Ybbd8\"' 88 `Y8a 8Y\"Ybbd8\"' 88 `\"8bbdP\"Y8 `\"Ybbd8\"' 88 `Y8a 88 `\"YbbdP\"' 88 88 88 \"Y888 ",
|
|
|
|
" ,88 ",
|
|
|
|
" 888P ",
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ncplane*
|
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:
Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:
decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.
There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().
This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.
The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.
Closes #638, #562, and #622.
4 years ago
|
|
|
make_slider(struct notcurses* nc, int dimy, int dimx){
|
|
|
|
// 600 frames in the video
|
|
|
|
const int len = strlen(leg[0]);
|
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:
Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:
decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.
There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().
This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.
The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.
Closes #638, #562, and #622.
4 years ago
|
|
|
const int REPS = 600 / len + dimx / len;
|
|
|
|
int y = dimy - sizeof(leg) / sizeof(*leg);
|
|
|
|
struct ncplane* n = ncplane_new(nc, sizeof(leg) / sizeof(*leg), len * REPS, y, 0, NULL);
|
|
|
|
uint64_t channels = 0;
|
|
|
|
channels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
|
|
|
|
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
|
|
|
|
ncplane_set_base(n, " ", 0, channels);
|
|
|
|
ncplane_set_scrolling(n, true);
|
|
|
|
int r = 0x5f;
|
|
|
|
int g = 0xaf;
|
|
|
|
int b = 0x84;
|
|
|
|
ncplane_set_bg_alpha(n, CELL_ALPHA_TRANSPARENT);
|
|
|
|
for(int x = 0 ; x < REPS ; ++x){
|
|
|
|
for(size_t l = 0 ; l < sizeof(leg) / sizeof(*leg) ; ++l){
|
|
|
|
ncplane_set_fg_rgb_clipped(n, r + 0x8 * l, g + 0x8 * l, b + 0x8 * l);
|
|
|
|
if(ncplane_set_bg_rgb(n, (l + 1) * 0x2, 0x20, (l + 1) * 0x2)){
|
|
|
|
ncplane_destroy(n);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if(ncplane_putstr_yx(n, l, x * len, leg[l]) != len){
|
|
|
|
ncplane_destroy(n);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int t = r;
|
|
|
|
r = g;
|
|
|
|
g = b;
|
|
|
|
b = t;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
perframecb(struct ncvisual* ncv __attribute__ ((unused)),
|
|
|
|
struct ncvisual_options* vopts,
|
|
|
|
const struct timespec* tspec, void* vnewplane){
|
|
|
|
struct notcurses* nc = ncplane_notcurses(vopts->n);
|
|
|
|
static int frameno = 0;
|
|
|
|
int y, x;
|
|
|
|
struct ncplane* n = vnewplane;
|
|
|
|
assert(n);
|
|
|
|
ncplane_yx(n, &y, &x);
|
|
|
|
ncplane_move_yx(n, y, x - 1);
|
|
|
|
++frameno;
|
|
|
|
DEMO_RENDER(nc);
|
|
|
|
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, tspec, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int xray_demo(struct notcurses* nc){
|
|
|
|
if(!notcurses_canopen_videos(nc)){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int dimx, dimy;
|
|
|
|
notcurses_term_dim_yx(nc, &dimy, &dimx);
|
|
|
|
struct ncplane* n = ncplane_new(nc, dimy, dimx, 0, 0, NULL);
|
|
|
|
if(n == NULL){
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
char* path = find_data("notcursesI.avi");
|
|
|
|
nc_err_e err;
|
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:
Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:
decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.
There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().
This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.
The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.
Closes #638, #562, and #622.
4 years ago
|
|
|
struct ncvisual* ncv = ncvisual_from_file(path, &err);
|
|
|
|
free(path);
|
|
|
|
if(ncv == NULL){
|
|
|
|
return -1;
|
|
|
|
}
|
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:
Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:
decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.
There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().
This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.
The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.
Closes #638, #562, and #622.
4 years ago
|
|
|
struct ncplane* newpanel = make_slider(nc, dimy, dimx);
|
|
|
|
if(newpanel == NULL){
|
|
|
|
ncvisual_destroy(ncv);
|
|
|
|
ncplane_destroy(n);
|
|
|
|
return -1;
|
|
|
|
}
|
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:
Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:
decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.
There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().
This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.
The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.
Closes #638, #562, and #622.
4 years ago
|
|
|
struct ncvisual_options vopts = {
|
|
|
|
.n = n,
|
|
|
|
.scaling = NCSCALE_STRETCH,
|
|
|
|
.blitter = NCBLIT_2x1,
|
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:
Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:
decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.
There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().
This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.
The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.
Closes #638, #562, and #622.
4 years ago
|
|
|
};
|
|
|
|
int ret = ncvisual_stream(nc, ncv, &err, 0.5 * delaymultiplier, perframecb, &vopts, newpanel);
|
|
|
|
ncvisual_destroy(ncv);
|
|
|
|
ncplane_destroy(n);
|
|
|
|
ncplane_destroy(newpanel);
|
|
|
|
return ret;
|
|
|
|
}
|