def real_smoothscale(src, size, dest=None): """ This scales src up or down to size. This uses both the pixellate and the transform operations to handle the scaling. """ width, height = size srcwidth, srcheight = src.get_size() iwidth, iheight = srcwidth, srcheight if dest is None: dest = pgrender.surface_unscaled(size, src) if width == 0 or height == 0: return dest xshrink = 1 yshrink = 1 while iwidth >= width * 2: xshrink *= 2 iwidth /= 2 while iheight >= height * 2: yshrink *= 2 iheight /= 2 if iwidth != srcwidth or iheight != srcheight: inter = pgrender.surface_unscaled((iwidth, iheight), src) real_renpy_pixellate(src, inter, xshrink, yshrink, 1, 1) src = inter real_renpy_transform(src, dest, 0, 0, 1.0 * iwidth / width, 0, 0, 1.0 * iheight / height, precise=1) return dest
def __init__(self, what, alpha=True, wh=None): if isinstance(what, PygameSurface): self.surface = what if wh is not None: self.width = int(wh[0]) self.height = int(wh[1]) else: self.width = int(math.ceil(self.surface.get_width() / factor)) self.height = int(math.ceil(self.surface.get_height() / factor)) else: w, h = what w = int(w) h = int(h) self.width = w self.height = h w = int(w * factor) h = int(h * factor) if isinstance(alpha, ScaledSurface): alpha = alpha.surface # E1103 self.surface = pgrender.surface_unscaled((w, h), alpha) self.virtx = 0 self.virty = 0 self.physx = 0 self.physy = 0
def __init__(self, what, alpha=True, wh=None): if isinstance(what, PygameSurface): self.surface = what if wh is not None: self.width = int(wh[0]) self.height = int(wh[1]) else: self.width = int( math.ceil(self.surface.get_width() / factor)) self.height = int( math.ceil(self.surface.get_height() / factor)) else: w, h = what w = int(w) h = int(h) self.width = w self.height = h w = int(w * factor) h = int(h * factor) if isinstance(alpha, ScaledSurface): alpha = alpha.surface # E1103 self.surface = pgrender.surface_unscaled((w, h), alpha) self.virtx = 0 self.virty = 0 self.physx = 0 self.physy = 0
def real_smoothscale(src, size, dest=None): """ This scales src up or down to size. This uses both the pixellate and the transform operations to handle the scaling. """ width, height = size srcwidth, srcheight = src.get_size() iwidth, iheight = srcwidth, srcheight if dest is None: dest = pgrender.surface_unscaled(size, src) if width == 0 or height == 0: return dest xshrink = 1 yshrink = 1 while iwidth >= width * 2: xshrink *= 2 iwidth /= 2 while iheight >= height * 2: yshrink *= 2 iheight /= 2 if iwidth != srcwidth or iheight != srcheight: inter = pgrender.surface_unscaled((iwidth, iheight), src) real_renpy_pixellate(src, inter, xshrink, yshrink, 1, 1) src = inter real_renpy_transform( src, dest, 0, 0, 1.0 * iwidth / width, 0, 0, 1.0 * iheight / height, precise=1, ) return dest
def real_bilinear(src, size): rv = pgrender.surface_unscaled(size, src) renpy.display.module.bilinear_scale(src, rv) return rv