def blit_2x( self, console: tcod.console.Console, dest_x: int, dest_y: int, img_x: int = 0, img_y: int = 0, img_width: int = -1, img_height: int = -1, ) -> None: """Blit onto a Console with double resolution. Args: console (Console): Blit destination Console. dest_x (int): Console tile X position starting from the left at 0. dest_y (int): Console tile Y position starting from the top at 0. img_x (int): Left corner pixel of the Image to blit img_y (int): Top corner pixel of the Image to blit img_width (int): Width of the Image to blit. Use -1 for the full Image width. img_height (int): Height of the Image to blit. Use -1 for the full Image height. """ lib.TCOD_image_blit_2x( self.image_c, _console(console), dest_x, dest_y, img_x, img_y, img_width, img_height, )
def blit( self, console: tcod.console.Console, x: float, y: float, bg_blend: int, scale_x: float, scale_y: float, angle: float, ) -> None: """Blit onto a Console using scaling and rotation. Args: console (Console): Blit destination Console. x (float): Console X position for the center of the Image blit. y (float): Console Y position for the center of the Image blit. The Image blit is centered on this position. bg_blend (int): Background blending mode to use. scale_x (float): Scaling along Image x axis. Set to 1 for no scaling. Must be over 0. scale_y (float): Scaling along Image y axis. Set to 1 for no scaling. Must be over 0. angle (float): Rotation angle in radians. (Clockwise?) """ lib.TCOD_image_blit( self.image_c, _console(console), x, y, bg_blend, scale_x, scale_y, angle, )
def refresh_console(self, console: tcod.console.Console) -> None: """Update an Image created with :any:`tcod.image_from_console`. The console used with this function should have the same width and height as the Console given to :any:`tcod.image_from_console`. The font width and height must also be the same as when :any:`tcod.image_from_console` was called. Args: console (Console): A Console with a pixel width and height matching this Image. """ lib.TCOD_image_refresh_console(self.image_c, _console(console))
def blit_rect( self, console: tcod.console.Console, x: int, y: int, width: int, height: int, bg_blend: int, ) -> None: """Blit onto a Console without scaling or rotation. Args: console (Console): Blit destination Console. x (int): Console tile X position starting from the left at 0. y (int): Console tile Y position starting from the top at 0. width (int): Use -1 for Image width. height (int): Use -1 for Image height. bg_blend (int): Background blending mode to use. """ lib.TCOD_image_blit_rect(self.image_c, _console(console), x, y, width, height, bg_blend)
def render(self, console: tcod.console.Console) -> np.ndarray: """Render an RGBA array, using console with this tileset. `console` is the Console object to render, this can not be the root console. The output array will be a np.uint8 array with the shape of: ``(con_height * tile_height, con_width * tile_width, 4)``. .. versionadded:: 11.9 """ if not console: raise ValueError("'console' must not be the root console.") width = console.width * self.tile_width height = console.height * self.tile_height out = np.empty((height, width, 4), np.uint8) out[:] = 9 surface_p = ffi.gc( lib.SDL_CreateRGBSurfaceWithFormatFrom( ffi.cast("void*", out.ctypes.data), width, height, 32, out.strides[0], lib.SDL_PIXELFORMAT_RGBA32, ), lib.SDL_FreeSurface, ) with surface_p: with ffi.new("SDL_Surface**", surface_p) as surface_p_p: _check( lib.TCOD_tileset_render_to_surface( self._tileset_p, _console(console), ffi.NULL, surface_p_p, ) ) return out