ncplane_highgradient: only pass a single channel #676

This commit is contained in:
nick black 2020-06-05 00:36:42 -04:00
parent de23139111
commit e1d34c4f43
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
7 changed files with 26 additions and 29 deletions

View File

@ -1169,8 +1169,8 @@ int ncplane_highgradient(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ystop, int xstop);
static inline int
ncplane_highgradient_sized(struct ncplane* n, uint64_t ul, uint64_t ur,
uint64_t ll, uint64_t lr, int ylen, int xlen){
ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ylen, int xlen){
if(ylen < 1 || xlen < 1){
return -1;
}

View File

@ -166,12 +166,12 @@ namespace ncpp
return error_guard<int> (ncplane_gradient_sized (plane, egc, attrword, ul, ur, ll, lr, ylen, xlen), -1);
}
int high_gradient (uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
int high_gradient (uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_highgradient (plane, ul, ur, ll, lr, ylen, xlen), -1);
}
int high_gradient_sized (uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
int high_gradient_sized (uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_highgradient_sized (plane, ul, ur, ll, lr, ylen, xlen), -1);
}

View File

@ -1625,8 +1625,8 @@ ncplane_gradient_sized(struct ncplane* n, const char* egc, uint32_t attrword,
}
static inline int
ncplane_highgradient_sized(struct ncplane* n, uint64_t ul, uint64_t ur,
uint64_t ll, uint64_t lr, int ylen, int xlen){
ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ylen, int xlen){
if(ylen < 1 || xlen < 1){
return -1;
}

View File

@ -48,15 +48,11 @@ int allglyphs_demo(struct notcurses* nc){
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_erase(n);
ncplane_cursor_move_yx(n, 0, 0);
uint64_t tl = 0, tr = 0, bl = 0, br = 0;
channels_set_fg_rgb(&tl, 0, 0, 0);
channels_set_fg_rgb(&tr, 0, 0xff, 0);
channels_set_fg_rgb(&bl, 0, 0, 0xff);
channels_set_fg_rgb(&br, 0, 0xff, 0xff);
channels_set_bg_rgb(&tl, 0, 0, 0);
channels_set_bg_rgb(&tr, 0, 0xff, 0);
channels_set_bg_rgb(&bl, 0, 0, 0xff);
channels_set_bg_rgb(&br, 0, 0xff, 0xff);
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
channel_set_rgb(&tl, 0, 0, 0);
channel_set_rgb(&tr, 0, 0xff, 0);
channel_set_rgb(&bl, 0, 0, 0xff);
channel_set_rgb(&br, 0, 0xff, 0xff);
if(ncplane_highgradient(n, tl, tr, bl, br, dimy - 1, dimx - 1) < 0){
return -1;
}

View File

@ -5,7 +5,7 @@
static int
rotate_plane(struct notcurses* nc, struct ncplane* n){
struct timespec scaled;
timespec_div(&demodelay, 8, &scaled);
timespec_div(&demodelay, 2, &scaled);
// we can't rotate a plane unless it has an even number of columns :/
int nx;
if((nx = ncplane_dim_x(n)) % 2){
@ -26,7 +26,10 @@ rotate_plane(struct notcurses* nc, struct ncplane* n){
ncplane_yx(n, &absy, &absx);
ncplane_move_yx(n, absy + centy - cent2y, absx + centx - cent2x);
DEMO_RENDER(nc);
timespec_mul(&scaled, 2, &scaled);
timespec_div(&scaled, 3, &scaled);
}
timespec_div(&demodelay, 2, &scaled);
for(int i = 0 ; i < 16 ; ++i){
demo_nanosleep(nc, &scaled);
int centy, centx;
@ -40,6 +43,8 @@ rotate_plane(struct notcurses* nc, struct ncplane* n){
ncplane_yx(n, &absy, &absx);
ncplane_move_yx(n, absy + centy - cent2y, absx + centx - cent2x);
DEMO_RENDER(nc);
timespec_mul(&scaled, 2, &scaled);
timespec_div(&scaled, 3, &scaled);
}
return 0;
}
@ -58,13 +63,13 @@ rotate_visual(struct notcurses* nc, struct ncplane* n, int dy, int dx){
n = notcurses_stddim_yx(nc, &dimy, &dimx);
bool failed = false;
const int ROTATIONS = 128;
timespec_div(&demodelay, ROTATIONS / 8, &scaled);
timespec_div(&demodelay, ROTATIONS, &scaled);
struct ncvisual_options vopts = {
};
ncplane_erase(n);
for(double i = 0 ; i < ROTATIONS ; ++i){
demo_nanosleep(nc, &scaled);
if(ncvisual_rotate(ncv, M_PI / 2)){
if(ncvisual_rotate(ncv, -M_PI / 2)){
failed = true;
break;
}

View File

@ -111,8 +111,8 @@ check_gradient_args(uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br){
// calculate both channels of a gradient at a particular point, knowing that
// we're using double halfblocks, into `c`->channels.
static inline void
calc_highgradient(cell* c, uint64_t ul, uint64_t ur, uint64_t ll,
uint64_t lr, int y, int x, int ylen, int xlen){
calc_highgradient(cell* c, uint32_t ul, uint32_t ur, uint32_t ll,
uint32_t lr, int y, int x, int ylen, int xlen){
if(!channel_default_p(ul)){
cell_set_fchannel(c, calc_gradient_channel(ul, ur, ll, lr,
y * 2, x, ylen, xlen));

View File

@ -13,15 +13,11 @@ rotate_grad(struct notcurses* nc){
int dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_cursor_move_yx(n, 0, 0);
uint64_t tl = 0, tr = 0, bl = 0, br = 0;
channels_set_fg_rgb(&tl, 0xff, 0, 0);
channels_set_fg_rgb(&tr, 0, 0, 0xff);
channels_set_fg_rgb(&bl, 0, 0xff, 0);
channels_set_fg_rgb(&br, 0, 0xff, 0xff);
channels_set_bg_rgb(&tl, 0xff, 0, 0);
channels_set_bg_rgb(&tr, 0, 0xff, 0);
channels_set_bg_rgb(&bl, 0, 0, 0xff);
channels_set_bg_rgb(&br, 0, 0xff, 0xff);
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
channel_set_rgb(&tl, 0xff, 0, 0);
channel_set_rgb(&tr, 0, 0, 0xff);
channel_set_rgb(&bl, 0, 0xff, 0);
channel_set_rgb(&br, 0, 0xff, 0xff);
if(ncplane_highgradient(n, tl, tr, bl, br, dimy - 1, dimx - 1) <= 0){
return -1;
}