def render(self, width, height, st, at): width = max(self.style.xminimum, width) height = max(self.style.yminimum, height) color = self.color or self.style.color rv = Render(width, height) if color is None or width <= 0 or height <= 0: return rv SIZE = 10 if width < SIZE or height < SIZE: tex = renpy.display.draw.solid_texture(width, height, color) else: tex = renpy.display.draw.solid_texture(SIZE, SIZE, color) rv.forward = Matrix2D(1.0 * SIZE / width, 0, 0, 1.0 * SIZE / height) rv.reverse = Matrix2D(1.0 * width / SIZE, 0, 0, 1.0 * height / SIZE) rv.blit(tex, (0, 0)) return rv
def render(self, width, height, st, at): color = self.color or self.style.color rv = Render(width, height) if color is None or width <= 0 or height <= 0: return rv SIZE = 10 si = renpy.display.im.SolidImage(color, SIZE, SIZE) sr = render(si, SIZE, SIZE, st, at) rv.forward = Matrix2D(1.0 * SIZE / width, 0, 0, 1.0 * SIZE / height) rv.reverse = Matrix2D(1.0 * width / SIZE, 0, 0, 1.0 * height / SIZE) rv.blit(sr, (0, 0)) return rv
def render(self, width, height, st, at): color = self.color or self.style.color rv = Render(width, height) if color is None or width <= 0 or height <= 0: return rv SIZE = 10 if width < SIZE or height < SIZE: tex = renpy.display.draw.solid_texture(width, height, color) else: tex = renpy.display.draw.solid_texture(SIZE, SIZE, color) rv.forward = Matrix2D(1.0 * SIZE / width, 0, 0, 1.0 * SIZE / height) rv.reverse = Matrix2D(1.0 * width / SIZE, 0, 0, 1.0 * height / SIZE) rv.blit(tex, (0, 0)) return rv
def draw(x0, x1, y0, y1): # Compute the coordinates of the left, right, top, and # bottom sides of the region, for both the source and # destination surfaces. # left side. if x0 >= 0: dx0 = x0 sx0 = x0 else: dx0 = dw + x0 sx0 = sw + x0 # right side. if x1 > 0: dx1 = x1 sx1 = x1 else: dx1 = dw + x1 sx1 = sw + x1 # top side. if y0 >= 0: dy0 = y0 sy0 = y0 else: dy0 = dh + y0 sy0 = sh + y0 # bottom side if y1 > 0: dy1 = y1 sy1 = y1 else: dy1 = dh + y1 sy1 = sh + y1 # Quick exit. if sx0 == sx1 or sy0 == sy1: return # Compute sizes. csw = sx1 - sx0 csh = sy1 - sy0 cdw = dx1 - dx0 cdh = dy1 - dy0 if csw <= 0 or csh <= 0 or cdh <= 0 or cdw <= 0: return # Get a subsurface. cr = crend.subsurface((sx0, sy0, csw, csh)) # Scale or tile if we have to. if csw != cdw or csh != cdh: if self.tile: newcr = Render(cdw, cdh) newcr.xclipping = True newcr.yclipping = True for x in xrange(0, cdw, csw): for y in xrange(0, cdh, csh): newcr.blit(cr, (x, y)) cr = newcr else: newcr = Render(cdw, cdh) newcr.forward = Matrix2D(1.0 * csw / cdw, 0, 0, 1.0 * csh / cdh) newcr.reverse = Matrix2D(1.0 * cdw / csw, 0, 0, 1.0 * cdh / csh) newcr.blit(cr, (0, 0)) cr = newcr # Blit. rv.blit(cr, (dx0, dy0)) return
def draw(x0, x1, y0, y1): # Compute the coordinates of the left, right, top, and # bottom sides of the region, for both the source and # destination surfaces. # left side. if x0 >= 0: dx0 = x0 sx0 = x0 else: dx0 = dw + x0 sx0 = sw + x0 # right side. if x1 > 0: dx1 = x1 sx1 = x1 else: dx1 = dw + x1 sx1 = sw + x1 # top side. if y0 >= 0: dy0 = y0 sy0 = y0 else: dy0 = dh + y0 sy0 = sh + y0 # bottom side if y1 > 0: dy1 = y1 sy1 = y1 else: dy1 = dh + y1 sy1 = sh + y1 # Quick exit. if sx0 == sx1 or sy0 == sy1: return # Compute sizes. csw = sx1 - sx0 csh = sy1 - sy0 cdw = dx1 - dx0 cdh = dy1 - dy0 if csw <= 0 or csh <= 0 or cdh <= 0 or cdw <= 0: return # Get a subsurface. cr = crend.subsurface((sx0, sy0, csw, csh)) # Scale or tile if we have to. if csw != cdw or csh != cdh: if self.tile: ctw, cth = cdw, cdh xtiles = max(1, cdw // csw + (1 if cdw % csw else 0)) ytiles = max(1, cdh // csh + (1 if cdh % csh else 0)) if cdw % csw or cdh % csh: # Area is not an exact integer number of tiles if self.tile == "integer": if cdw % csw / float(csw) < self.tile_ratio: xtiles = max(1, xtiles - 1) if cdh % csh / float(csh) < self.tile_ratio: ytiles = max(1, ytiles - 1) # Set size of the used tiles (ready to scale) ctw, cth = csw * xtiles, csh * ytiles newcr = Render(ctw, cth) newcr.xclipping = True newcr.yclipping = True for x in range(0, xtiles): for y in range(0, ytiles): newcr.blit(cr, (x * csw, y * csh)) csw, csh = ctw, cth cr = newcr if csw != cdw or csh != cdh: # Subsurface needs scaling newcr = Render(cdw, cdh) newcr.forward = Matrix2D(1.0 * csw / cdw, 0, 0, 1.0 * csh / cdh) newcr.reverse = Matrix2D(1.0 * cdw / csw, 0, 0, 1.0 * cdh / csh) newcr.blit(cr, (0, 0)) cr = newcr # Blit. rv.blit(cr, (dx0, dy0)) return