add NCSCALE_INFLATE

This commit is contained in:
nick black 2021-05-12 13:07:23 -04:00
parent 9ce8222d36
commit 8bd73378cf
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
5 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,9 @@
This document attempts to list user-visible changes and any major internal This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses. rearrangements of Notcurses.
* 2.3.1 (not yet released)
* Add `NCSCALE_INFLATE`.
* 2.3.0 (2021-05-09) **"Triumph"** * 2.3.0 (2021-05-09) **"Triumph"**
* No user-visible changes. * No user-visible changes.

View File

@ -3203,9 +3203,13 @@ typedef enum {
NCSCALE_NONE, NCSCALE_NONE,
NCSCALE_SCALE, NCSCALE_SCALE,
NCSCALE_STRETCH, NCSCALE_STRETCH,
NCSCALE_SCALE_HIRES,
NCSCALE_NONE_HIRES,
NCSCALE_INFLATE,
} ncscale_e; } ncscale_e;
// Lex a scaling mode (one of "none", "stretch", "scale", "hires", or "scalehi"). // Lex a scaling mode (one of "none", "stretch", "scale", "hires",
// "inflate", or "scalehi").
int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode); int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode);
// Get the name of a scaling mode. // Get the name of a scaling mode.

View File

@ -16,6 +16,7 @@ typedef enum {
NCSCALE_STRETCH, NCSCALE_STRETCH,
NCSCALE_NONE_HIRES, NCSCALE_NONE_HIRES,
NCSCALE_SCALE_HIRES, NCSCALE_SCALE_HIRES,
NCSCALE_INFLATE,
} ncscale_e; } ncscale_e;
typedef enum { typedef enum {
@ -225,8 +226,8 @@ instance **NCSCALE_SCALE_HIRES** and a large image), more rows and columns will
result in more effective resolution. result in more effective resolution.
A string can be transformed to a scaling mode with **notcurses_lex_scalemode**, A string can be transformed to a scaling mode with **notcurses_lex_scalemode**,
recognizing **stretch**, **scalehi**, **hires**, **scale**, and **none**. recognizing **stretch**, **scalehi**, **hires**, **scale**, **inflate**, and
Conversion in the opposite direction is performed with **none**. Conversion in the opposite direction is performed with
**notcurses_str_scalemode**. **notcurses_str_scalemode**.
Assuming a cell is twice as tall as it is wide, **NCBLIT_1x1** (and indeed Assuming a cell is twice as tall as it is wide, **NCBLIT_1x1** (and indeed

View File

@ -86,16 +86,18 @@ typedef enum {
// How to scale an ncvisual during rendering. NCSCALE_NONE will apply no // How to scale an ncvisual during rendering. NCSCALE_NONE will apply no
// scaling. NCSCALE_SCALE scales a visual to the plane's size, maintaining // scaling. NCSCALE_SCALE scales a visual to the plane's size, maintaining
// aspect ratio. NCSCALE_STRETCH stretches and scales the image in an // aspect ratio. NCSCALE_INFLATE does the same, but without interpolation.
// attempt to fill the entirety of the plane. NCSCALE_NONE_HIRES and // NCSCALE_STRETCH stretches and scales the image in an attempt to fill the
// NCSCALE_SCALE_HIRES behave like their counterparts, but admit blitters // entirety of the plane. NCSCALE_NONE_HIRES and NCSCALE_SCALE_HIRES behave
// which don't preserve aspect ratio. // like their counterparts, but admit blitters which don't preserve aspect
// ratio.
typedef enum { typedef enum {
NCSCALE_NONE, NCSCALE_NONE,
NCSCALE_SCALE, NCSCALE_SCALE,
NCSCALE_STRETCH, NCSCALE_STRETCH,
NCSCALE_NONE_HIRES, NCSCALE_NONE_HIRES,
NCSCALE_SCALE_HIRES, NCSCALE_SCALE_HIRES,
NCSCALE_INFLATE,
} ncscale_e; } ncscale_e;
// Returns the number of columns occupied by a multibyte (UTF-8) string, or // Returns the number of columns occupied by a multibyte (UTF-8) string, or
@ -905,7 +907,8 @@ API int notcurses_lex_blitter(const char* op, ncblitter_e* blitter);
// Get the name of a blitter. // Get the name of a blitter.
API const char* notcurses_str_blitter(ncblitter_e blitter); API const char* notcurses_str_blitter(ncblitter_e blitter);
// Lex a scaling mode (one of "none", "stretch", "scale", "hires", or "scalehi"). // Lex a scaling mode (one of "none", "stretch", "scale", "hires",
// "scalehi", or "inflate").
API int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode); API int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode);
// Get the name of a scaling mode. // Get the name of a scaling mode.

View File

@ -2533,6 +2533,8 @@ lex_long(const char* op, int* i, char** endptr){
int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode){ int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode){
if(strcasecmp(op, "stretch") == 0){ if(strcasecmp(op, "stretch") == 0){
*scalemode = NCSCALE_STRETCH; *scalemode = NCSCALE_STRETCH;
}else if(strcasecmp(op, "inflate") == 0){
*scalemode = NCSCALE_INFLATE;
}else if(strcasecmp(op, "scalehi") == 0){ }else if(strcasecmp(op, "scalehi") == 0){
*scalemode = NCSCALE_SCALE_HIRES; *scalemode = NCSCALE_SCALE_HIRES;
}else if(strcasecmp(op, "hires") == 0){ }else if(strcasecmp(op, "hires") == 0){
@ -2550,6 +2552,8 @@ int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode){
const char* notcurses_str_scalemode(ncscale_e scalemode){ const char* notcurses_str_scalemode(ncscale_e scalemode){
if(scalemode == NCSCALE_STRETCH){ if(scalemode == NCSCALE_STRETCH){
return "stretch"; return "stretch";
}else if(scalemode == NCSCALE_INFLATE){
return "inflate";
}else if(scalemode == NCSCALE_SCALE){ }else if(scalemode == NCSCALE_SCALE){
return "scale"; return "scale";
}else if(scalemode == NCSCALE_NONE){ }else if(scalemode == NCSCALE_NONE){