Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
blitset.h
Go to the documentation of this file.
1#ifndef NOTCURSES_BLITSET
2#define NOTCURSES_BLITSET
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "blit.h"
9
10// number of pixels that map to a single cell, height-wise
11static inline int
12encoding_y_scale(const tinfo* tcache, const struct blitset* bset) {
13 if(bset->geom == NCBLIT_PIXEL){
14 return tcache->cellpxy;
15 }
16 return bset->height;
17}
18
19// number of pixels that map to a single cell, width-wise
20static inline int
21encoding_x_scale(const tinfo* tcache, const struct blitset* bset) {
22 if(bset->geom == NCBLIT_PIXEL){
23 return tcache->cellpxx;
24 }
25 return bset->width;
26}
27
28// Expand NCBLIT_DEFAULT for media blitting, based on environment. We never
29// use NCBLIT_PIXEL for NCBLIT_DEFAULT, though maybe this ought change.
30static inline ncblitter_e
31rgba_blitter_default(const tinfo* tcache, ncscale_e scale){
32 if(!tcache->caps.utf8){
33 return NCBLIT_1x1; // only one that works in ASCII
34 }
35 if(scale == NCSCALE_NONE || scale == NCSCALE_SCALE){
36 return NCBLIT_2x1;
37 }
38 if(tcache->caps.octants){
39 return NCBLIT_4x2;
40 }
41 if(tcache->caps.sextants){
42 return NCBLIT_3x2;
43 }
44 if(tcache->caps.quadrants){
45 return NCBLIT_2x2;
46 }
47 return NCBLIT_2x1;
48}
49
50static inline ncblitter_e
51ncplot_defblitter(const notcurses* nc){
52 if(notcurses_canutf8(nc)){
53 return NCBLIT_8x1;
54 }
55 return NCBLIT_1x1;
56}
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
ncscale_e
Definition notcurses.h:96
@ NCSCALE_SCALE
Definition notcurses.h:98
@ NCSCALE_NONE
Definition notcurses.h:97
ncblitter_e
Definition notcurses.h:65
@ NCBLIT_PIXEL
Definition notcurses.h:73
@ NCBLIT_4x2
Definition notcurses.h:71
@ NCBLIT_2x2
Definition notcurses.h:69
@ NCBLIT_3x2
Definition notcurses.h:70
@ NCBLIT_1x1
Definition notcurses.h:67
@ NCBLIT_2x1
Definition notcurses.h:68
@ NCBLIT_8x1
Definition notcurses.h:76
ncblitter_e geom
Definition internal.h:399
unsigned width
Definition internal.h:400
unsigned height
Definition internal.h:401
unsigned cellpxx
Definition termdesc.h:117
nccapabilities caps
Definition termdesc.h:111
unsigned cellpxy
Definition termdesc.h:116