remove undesired gap between pages if autofit scaling in double mode

This commit is contained in:
multiSnow 2022-12-07 02:06:00 +08:00
parent 9a27947eda
commit 03c06e980d
Signed by: multiSnow
GPG Key ID: 18EDAC29CAA2DBCE
1 changed files with 22 additions and 23 deletions

View File

@ -346,29 +346,28 @@ def draw_dual_canvas(self):
canvasr.draw(srcrect=srcrectr,dstrect=dstrectr)
return preload_canvas(self)
else:
# autofit, downscale only if canvas is larger than output size.
# always show in left/rigt center, ignore canvas_offset
# place split gap in middle of window
srcrectl=srcrectr=None # entire texture
outer_width=max(dpl_w,dpr_w)*2
scale=min(area_w/outer_width,area_h/dp_h,1)
pge_x=area_w/2-dpl_w*scale
pge_y=(area_h-dp_h*scale)/2
pge_w=dp_w*scale
pge_h=dp_h*scale
dstl_x=dpl_x*scale+pge_x
dstr_x=dpr_x*scale+area_w/2
dstl_y=dpl_y*scale+pge_y
dstr_y=dpr_y*scale+pge_y
dstl_w=srcl_w*scale*scale_l
dstl_h=srcl_h*scale*scale_l
dstr_w=srcr_w*scale*scale_r
dstr_h=srcr_h*scale*scale_r
# apply area offset
pgerect=(*map(int,(pge_x+area_x,pge_y+area_y,pge_w,pge_h)),)
dstrectl=(*map(int,(dstl_x+area_x,dstl_y+area_y,dstl_w,dstl_h)),)
dstrectr=(*map(int,(dstr_x+area_x,dstr_y+area_y,dstr_w,dstr_h)),)
# autofit, downscale only if canvas is larger than output size.
# always show in left/rigt center, ignore canvas_offset
# place split gap in middle of window
srcrectl=srcrectr=None # entire texture
outer_width=max(dpl_w,dpr_w)*2
scale=min(area_w/outer_width,area_h/dp_h,1)
pge_x=area_w/2-dpl_w*scale
pge_y=(area_h-dp_h*scale)/2
pge_w=dp_w*scale
pge_h=dp_h*scale
dstl_x=dpl_x*scale+pge_x
dstr_x=dpr_x*scale+area_w/2
dstl_y=dpl_y*scale+pge_y
dstr_y=dpr_y*scale+pge_y
dstl_w=srcl_w*scale*scale_l
dstl_h=srcl_h*scale*scale_l
dstr_w=srcr_w*scale*scale_r
dstr_h=srcr_h*scale*scale_r
# apply area offset
pgerect=(*map(int,(pge_x+area_x,pge_y+area_y)),*map(ceil,(pge_w,pge_h)))
dstrectl=(*map(int,(dstl_x+area_x,dstl_y+area_y)),*map(ceil,(dstl_w,dstl_h)))
dstrectr=(*map(int,(dstr_x+area_x,dstr_y+area_y)),*map(ceil,(dstr_w,dstr_h)))
if self.checker:
if self.use_page and (canvasl.has_page or canvasr.has_page):