mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
eagle: always zoom to target area #732
This commit is contained in:
parent
f99f64d3d7
commit
0c6f160493
@ -49,14 +49,16 @@ zoom_map(struct notcurses* nc, const char* map, int* ret){
|
|||||||
}
|
}
|
||||||
//fprintf(stderr, "VHEIGHT: %d VWIDTH: %d scale: %d/%d\n", vheight, vwidth, yscale, xscale);
|
//fprintf(stderr, "VHEIGHT: %d VWIDTH: %d scale: %d/%d\n", vheight, vwidth, yscale, xscale);
|
||||||
// we start at the lower left corner of the outzoomed map
|
// we start at the lower left corner of the outzoomed map
|
||||||
int truex, truey; // dimensions of true display
|
int placey, placex; // dimensions of true display
|
||||||
notcurses_term_dim_yx(nc, &truey, &truex);
|
notcurses_term_dim_yx(nc, &placey, &placex);
|
||||||
int delty = 2;
|
float delty = 3;
|
||||||
int deltx = 2;
|
float deltx = 3;
|
||||||
|
float truey = placey;
|
||||||
|
float truex = placex;
|
||||||
if(truey > truex){
|
if(truey > truex){
|
||||||
++delty;
|
delty *= truey / truex;
|
||||||
}else if(truex > truey){
|
}else{
|
||||||
++deltx;
|
deltx *= truex / truey;
|
||||||
}
|
}
|
||||||
// to zoom in on the map, we're going to scale the full image to a plane
|
// to zoom in on the map, we're going to scale the full image to a plane
|
||||||
// which grows on each iteration. it starts at the standard plane size,
|
// which grows on each iteration. it starts at the standard plane size,
|
||||||
@ -76,7 +78,7 @@ zoom_map(struct notcurses* nc, const char* map, int* ret){
|
|||||||
ncplane_destroy(zncp);
|
ncplane_destroy(zncp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while(vheight > truey && vwidth > truex){
|
while(vheight > truey || vwidth > truex){
|
||||||
*ret = -1;
|
*ret = -1;
|
||||||
ncplane_destroy(zncp);
|
ncplane_destroy(zncp);
|
||||||
if((zncp = ncplane_new(nc, truey, truex, 0, 0, NULL)) == NULL){
|
if((zncp = ncplane_new(nc, truey, truex, 0, 0, NULL)) == NULL){
|
||||||
|
Loading…
Reference in New Issue
Block a user