|
|
|
#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){
|
|
|
|
// 487 frames in the video
|
|
|
|
const int len = strlen(leg[0]);
|
|
|
|
const int REPS = 487 / len + dimx / len;
|
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 y = dimy - sizeof(leg) / sizeof(*leg);
|
|
|
|
struct ncplane_options nopts = {
|
|
|
|
.y = y,
|
|
|
|
.x = 0,
|
|
|
|
.rows = sizeof(leg) / sizeof(*leg),
|
|
|
|
.cols = len * REPS,
|
|
|
|
.name = "scrl",
|
|
|
|
};
|
|
|
|
struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts);
|
|
|
|
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_rgb8_clipped(n, r + 0x8 * l, g + 0x8 * l, b + 0x8 * l);
|
|
|
|
if(ncplane_set_bg_rgb8(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, struct ncvisual_options* vopts,
|
|
|
|
const struct timespec* tspec, void* vnewplane){
|
|
|
|
(void)ncv;
|
|
|
|
// only need these two steps done once, but we can't do them in
|
|
|
|
// main() due to the plane being created in ncvisual_stream() =[
|
|
|
|
ncplane_set_resizecb(vopts->n, ncplane_resize_maximize);
|
|
|
|
ncplane_move_above(vopts->n, vnewplane);
|
|
|
|
|
|
|
|
struct notcurses* nc = ncplane_notcurses(vopts->n);
|
|
|
|
static int frameno = 0;
|
|
|
|
int x;
|
|
|
|
struct ncplane* n = vnewplane;
|
|
|
|
assert(n);
|
|
|
|
ncplane_yx(n, NULL, &x);
|
|
|
|
ncplane_move_yx(n, 1, 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);
|
|
|
|
ncplane_erase(notcurses_stdplane(nc));
|
|
|
|
char* path = find_data("notcursesIII.mkv");
|
|
|
|
struct ncvisual* ncv = ncvisual_from_file(path);
|
|
|
|
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);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
uint64_t stdc = 0;
|
|
|
|
channels_set_fg_alpha(&stdc, CELL_ALPHA_TRANSPARENT);
|
|
|
|
channels_set_bg_alpha(&stdc, CELL_ALPHA_TRANSPARENT);
|
|
|
|
ncplane_set_base(notcurses_stdplane(nc), "", 0, stdc);
|
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 = {
|
|
|
|
.y = NCALIGN_CENTER,
|
|
|
|
.x = NCALIGN_CENTER,
|
|
|
|
.scaling = NCSCALE_SCALE_HIRES,
|
|
|
|
.blitter = NCBLIT_PIXEL,
|
|
|
|
.flags = NCVISUAL_OPTION_NODEGRADE // to test for NCBLIT_PIXEL
|
|
|
|
| NCVISUAL_OPTION_VERALIGNED | NCVISUAL_OPTION_HORALIGNED
|
|
|
|
| NCVISUAL_OPTION_ADDALPHA,
|
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
|
|
|
};
|
|
|
|
float dm = 0;
|
|
|
|
// returns non-zero if the selected blitter isn't available
|
|
|
|
if(ncvisual_blitter_geom(nc, ncv, &vopts, NULL, NULL, NULL, NULL, NULL)){
|
|
|
|
vopts.flags &= ~NCVISUAL_OPTION_NODEGRADE;
|
|
|
|
dm = 0.5 * delaymultiplier;
|
|
|
|
}
|
|
|
|
int ret = ncvisual_stream(nc, ncv, dm, perframecb, &vopts, newpanel);
|
|
|
|
ncvisual_destroy(ncv);
|
|
|
|
ncplane_destroy(newpanel);
|
|
|
|
return ret;
|
|
|
|
}
|