mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
[zoo] clean up background
This commit is contained in:
parent
8dc396c916
commit
4153e24f8b
@ -2,27 +2,29 @@
|
|||||||
|
|
||||||
// open up changes.jpg, stretch it to fill, drop it to greyscale
|
// open up changes.jpg, stretch it to fill, drop it to greyscale
|
||||||
static int
|
static int
|
||||||
draw_background(struct notcurses* nc){
|
draw_background(struct notcurses* nc, struct ncplane** bgp){
|
||||||
if(notcurses_canopen_images(nc)){
|
*bgp = NULL;
|
||||||
struct ncplane* n = notcurses_stdplane(nc);
|
if(!notcurses_canopen_images(nc)){
|
||||||
char* path = find_data("changes.jpg");
|
return 0;
|
||||||
struct ncvisual* ncv = ncvisual_from_file(path);
|
|
||||||
free(path);
|
|
||||||
if(!ncv){
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
struct ncvisual_options vopts = {
|
|
||||||
.scaling = NCSCALE_STRETCH,
|
|
||||||
.n = n,
|
|
||||||
.flags = NCVISUAL_OPTION_CHILDPLANE,
|
|
||||||
};
|
|
||||||
if(ncvisual_blit(nc, ncv, &vopts) == NULL){
|
|
||||||
ncvisual_destroy(ncv);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ncplane_greyscale(n);
|
|
||||||
ncvisual_destroy(ncv);
|
|
||||||
}
|
}
|
||||||
|
struct ncplane* n = notcurses_stdplane(nc);
|
||||||
|
char* path = find_data("changes.jpg");
|
||||||
|
struct ncvisual* ncv = ncvisual_from_file(path);
|
||||||
|
free(path);
|
||||||
|
if(!ncv){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
struct ncvisual_options vopts = {
|
||||||
|
.scaling = NCSCALE_STRETCH,
|
||||||
|
.n = n,
|
||||||
|
.flags = NCVISUAL_OPTION_CHILDPLANE,
|
||||||
|
};
|
||||||
|
if((*bgp = ncvisual_blit(nc, ncv, &vopts)) == NULL){
|
||||||
|
ncvisual_destroy(ncv);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ncplane_greyscale(n);
|
||||||
|
ncvisual_destroy(ncv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +440,11 @@ done:
|
|||||||
// screen. as it does so, two widgets (selector and multiselector) come in
|
// screen. as it does so, two widgets (selector and multiselector) come in
|
||||||
// from the left and right, respectively. they then fade out.
|
// from the left and right, respectively. they then fade out.
|
||||||
int zoo_demo(struct notcurses* nc){
|
int zoo_demo(struct notcurses* nc){
|
||||||
if(draw_background(nc)){
|
struct ncplane* bgp;
|
||||||
|
if(draw_background(nc, &bgp)){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return reader_demo(nc);
|
int ret = reader_demo(nc);
|
||||||
|
ncplane_destroy(bgp);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user