demo: use NCPLOT_OPTIONS_EXPOENTIALD #470

dankamongmen/speedy-blend
nick black 4 years ago committed by Nick Black
parent 2cfa3bb3dc
commit a440382fb5

@ -21,6 +21,10 @@ typedef enum {
NCPLOT_8x1, // eight vert/horz levels █▇▆▅▄▃▂▁ / ▏▎▍▌▋▊▉█
} ncgridgeom_e;
#define NCPLOT_OPTIONS_LABELTICKSD 0x0001
#define NCPLOT_OPTIONS_EXPONENTIALD 0x0002
#define NCPLOT_OPTIONS_VERTICALI 0x0004
typedef struct ncplot_options {
// channels for the maximum and minimum levels.
// lerp across the domain between these two.
@ -90,7 +94,12 @@ be difficult to differentiate at small text sizes. Quadrants and braille allow
for more resolution on the independent variable. It can be difficult to predict
how the braille glyphs will look in a given font.
The same **ncplot_options** struct can be used with all ncplot types.
The same **ncplot_options** struct can be used with all ncplot types. The
**flags** field is a bitmask composed of:
* **NCPLOT_OPTIONS_LABELTICKSD**: Label dependent axis ticks.
* **NCPLOT_OPTIONS_EXPONENTIALD**: Use an exponential dependent axis.
* **NCPLOT_OPTIONS_VERTICALI**: Vertical independent axis.
# NOTES

@ -2702,9 +2702,9 @@ typedef enum {
//
// This options structure works for both the ncuplot (uint64_t) and ncdplot
// (double) types.
#define NCPLOT_OPTIONS_LABELAXISD 0x0001 // show labels for dependent axis
#define NCPLOT_OPTIONS_EXPONENTIALY 0x0002 // exponential y-axis
#define NCPLOT_OPTIONS_VERINDEP 0x0004 // independent variable is vertical
#define NCPLOT_OPTIONS_LABELTICKSD 0x0001 // show labels for dependent axis
#define NCPLOT_OPTIONS_EXPONENTIALD 0x0002 // exponential dependent axis
#define NCPLOT_OPTIONS_VERTICALI 0x0004 // independent axis is vertical
typedef struct ncplot_options {
// channels for the maximum and minimum levels. linear interpolation will be

@ -511,7 +511,7 @@ int fpsgraph_init(struct notcurses* nc){
ncplane_set_base(newp, "", attrword, channels);
ncplot_options opts;
memset(&opts, 0, sizeof(opts));
opts.flags = NCPLOT_OPTIONS_LABELAXISD;
opts.flags = NCPLOT_OPTIONS_LABELTICKSD | NCPLOT_OPTIONS_EXPONENTIALD;
opts.gridtype = NCPLOT_8x1;
channels_set_fg_rgb(&opts.minchannel, 0x40, 0x50, 0xb0);
channels_set_bg(&opts.minchannel, 0x104010);

@ -215,7 +215,7 @@ int main(void){
auto n = nc.get_stdplane(&dimy, &dimx);
ncpp::Plane pplane{PLOTHEIGHT, dimx, dimy - PLOTHEIGHT, 0, nullptr};
struct ncplot_options popts{};
popts.flags = NCPLOT_OPTIONS_LABELAXISD;
popts.flags = NCPLOT_OPTIONS_LABELTICKSD;
popts.minchannel = popts.maxchannel = 0;
channels_set_fg_rgb(&popts.minchannel, 0x40, 0x50, 0xb0);
channels_set_fg_rgb(&popts.maxchannel, 0x40, 0xff, 0xd0);

@ -57,7 +57,7 @@ class ncppplot {
if(dimx < ncpp->rangex){
ncpp->slotcount = scaleddim;
}
if( (ncpp->labelaxisd = opts->flags & NCPLOT_OPTIONS_LABELAXISD) ){
if( (ncpp->labelaxisd = opts->flags & NCPLOT_OPTIONS_LABELTICKSD) ){
if(ncpp->slotcount + scaledprefixlen > scaleddim){
if(scaleddim > scaledprefixlen){
ncpp->slotcount = scaleddim - scaledprefixlen;
@ -73,9 +73,9 @@ class ncppplot {
ncpp->minchannel = opts->minchannel;
ncpp->miny = miny;
ncpp->maxy = maxy;
ncpp->vertical_indep = opts->flags & NCPLOT_OPTIONS_VERINDEP;
ncpp->vertical_indep = opts->flags & NCPLOT_OPTIONS_VERTICALI;
ncpp->gridtype = opts->gridtype;
ncpp->exponentially = opts->flags & NCPLOT_OPTIONS_EXPONENTIALY;
ncpp->exponentially = opts->flags & NCPLOT_OPTIONS_EXPONENTIALD;
if( (ncpp->detectdomain = (miny == maxy)) ){
ncpp->maxy = 0;
ncpp->miny = std::numeric_limits<T>::max();

Loading…
Cancel
Save