signature
stringlengths 8
3.44k
| body
stringlengths 0
1.41M
| docstring
stringlengths 1
122k
| id
stringlengths 5
17
|
---|---|---|---|
def __init__(self, initial=None, name=None): | self.name = name<EOL>self.initial = initial<EOL> | :param initial:
Initial value of this property.
:param name:
Name of this property. If not provided and if this is used with
:class:`.ViewModel`, name will be set automatically to name
of property. | f3100:c6:m0 |
def RaisePropertyChanged(self, property_name): | args = PropertyChangedEventArgs(property_name)<EOL>for handler in self.property_chaged_handlers:<EOL><INDENT>handler(self, args)<EOL><DEDENT> | Raises event that property value has changed for provided property name.
:param str property_name:
Name of property whose value has changed. | f3100:c8:m1 |
def Execute(self, parameter): | self.execute()<EOL> | Executes handler for this command. | f3100:c9:m1 |
def add_CanExecuteChanged(self, handler): | self._can_execute_changed_handlers.append(handler)<EOL> | Adds new listener to CanExecuteChanged event. | f3100:c9:m2 |
def remove_CanExecuteChanged(self, handler): | self._can_execute_changed_handlers.remove(handler)<EOL> | Removes listener for CanExecuteChanged event. | f3100:c9:m3 |
def RaiseCanExecuteChanged(self): | for handler in self._can_execute_changed_handlers:<EOL><INDENT>handler(self, EventArgs.Empty)<EOL><DEDENT> | Raises CanExecuteChanged event. | f3100:c9:m4 |
def CanExecute(self, parameter): | if self.can_execute:<EOL><INDENT>return self.can_execute()<EOL><DEDENT>return True<EOL> | Returns `True` if command can be executed, `False` otherwise. | f3100:c9:m5 |
def __init__(self, handler, can_execute=None): | self._handler = handler<EOL>self._can_execute = can_execute<EOL>self._command = None<EOL> | :param callable handler:
Method that will be called when command executed.
:param callable can_execute:
Method that will be called when GUI needs information if command
can be executed. If not provided, default implementation always
returns `True`. | f3100:c10:m0 |
def can_execute(self, can_execute): | self._can_execute = can_execute<EOL> | Decorator that adds function that determines if command can be executed.
Decorated function should return `True` if command can be executed
and false if it can not. | f3100:c10:m2 |
@ffi.def_extern() <EOL>def _pycall_path_old(x1: int, y1: int, x2: int, y2: int, handle: Any) -> float: | func, userData = ffi.from_handle(handle)<EOL>return func(x1, y1, x2, y2, userData)<EOL> | libtcodpy style callback, needs to preserve the old userData issue. | f3105:m0 |
@ffi.def_extern() <EOL>def _pycall_path_simple(<EOL>x1: int, y1: int, x2: int, y2: int, handle: Any<EOL>) -> float: | return ffi.from_handle(handle)(x1, y1, x2, y2)<EOL> | Does less and should run faster, just calls the handle function. | f3105:m1 |
@ffi.def_extern() <EOL>def _pycall_path_swap_src_dest(<EOL>x1: int, y1: int, x2: int, y2: int, handle: Any<EOL>) -> float: | return ffi.from_handle(handle)(x2, y2, x1, y1)<EOL> | A TDL function dest comes first to match up with a dest only call. | f3105:m2 |
@ffi.def_extern() <EOL>def _pycall_path_dest_only(<EOL>x1: int, y1: int, x2: int, y2: int, handle: Any<EOL>) -> float: | return ffi.from_handle(handle)(x2, y2)<EOL> | A TDL function which samples the dest coordinate only. | f3105:m3 |
def _get_pathcost_func(<EOL>name: str<EOL>) -> Callable[[int, int, int, int, Any], float]: | return ffi.cast( <EOL>"<STR_LIT>", ffi.addressof(lib, name)<EOL>)<EOL> | Return a properly cast PathCostArray callback. | f3105:m4 |
def get_tcod_path_ffi(self) -> Tuple[Any, Any, Tuple[int, int]]: | return self._CALLBACK_P, ffi.new_handle(self._userdata), self.shape<EOL> | Return (C callback, userdata handle, shape) | f3105:c0:m1 |
def __new__(cls, array: np.array) -> "<STR_LIT>": | self = np.asarray(array).view(cls)<EOL>return self<EOL> | Validate a numpy array and setup a C callback. | f3105:c2:m0 |
def get_path(<EOL>self, start_x: int, start_y: int, goal_x: int, goal_y: int<EOL>) -> List[Tuple[int, int]]: | lib.TCOD_path_compute(self._path_c, start_x, start_y, goal_x, goal_y)<EOL>path = []<EOL>x = ffi.new("<STR_LIT>")<EOL>y = x + <NUM_LIT:1><EOL>while lib.TCOD_path_walk(self._path_c, x, y, False):<EOL><INDENT>path.append((x[<NUM_LIT:0>], y[<NUM_LIT:0>]))<EOL><DEDENT>return path<EOL> | Return a list of (x, y) steps to reach the goal point, if possible.
Args:
start_x (int): Starting X position.
start_y (int): Starting Y position.
goal_x (int): Destination X position.
goal_y (int): Destination Y position.
Returns:
List[Tuple[int, int]]:
A list of points, or an empty list if there is no valid path. | f3105:c4:m0 |
def set_goal(self, x: int, y: int) -> None: | lib.TCOD_dijkstra_compute(self._path_c, x, y)<EOL> | Set the goal point and recompute the Dijkstra path-finder. | f3105:c5:m0 |
def get_path(self, x: int, y: int) -> List[Tuple[int, int]]: | lib.TCOD_dijkstra_path_set(self._path_c, x, y)<EOL>path = []<EOL>pointer_x = ffi.new("<STR_LIT>")<EOL>pointer_y = pointer_x + <NUM_LIT:1><EOL>while lib.TCOD_dijkstra_path_walk(self._path_c, pointer_x, pointer_y):<EOL><INDENT>path.append((pointer_x[<NUM_LIT:0>], pointer_y[<NUM_LIT:0>]))<EOL><DEDENT>return path<EOL> | Return a list of (x, y) steps to reach the goal point, if possible. | f3105:c5:m1 |
def __setitem__(self, index: Any, value: Any) -> None: | np.ndarray.__setitem__(self, index, value)<EOL>if self._image_c is not None:<EOL><INDENT>lib.TCOD_image_invalidate_mipmaps(self._image_c)<EOL><DEDENT> | Must invalidate mipmaps on any write. | f3106:c0:m3 |
def clear(self, color: Tuple[int, int, int]) -> None: | lib.TCOD_image_clear(self.image_c, color)<EOL> | Fill this entire Image with color.
Args:
color (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance. | f3106:c1:m2 |
def invert(self) -> None: | lib.TCOD_image_invert(self.image_c)<EOL> | Invert all colors in this Image. | f3106:c1:m3 |
def hflip(self) -> None: | lib.TCOD_image_hflip(self.image_c)<EOL> | Horizontally flip this Image. | f3106:c1:m4 |
def rotate90(self, rotations: int = <NUM_LIT:1>) -> None: | lib.TCOD_image_rotate90(self.image_c, rotations)<EOL> | Rotate this Image clockwise in 90 degree steps.
Args:
rotations (int): Number of 90 degree clockwise rotations. | f3106:c1:m5 |
def vflip(self) -> None: | lib.TCOD_image_vflip(self.image_c)<EOL> | Vertically flip this Image. | f3106:c1:m6 |
def scale(self, width: int, height: int) -> None: | lib.TCOD_image_scale(self.image_c, width, height)<EOL>self.width, self.height = width, height<EOL> | Scale this Image to the new width and height.
Args:
width (int): The new width of the Image after scaling.
height (int): The new height of the Image after scaling. | f3106:c1:m7 |
def set_key_color(self, color: Tuple[int, int, int]) -> None: | lib.TCOD_image_set_key_color(self.image_c, color)<EOL> | Set a color to be transparent during blitting functions.
Args:
color (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance. | f3106:c1:m8 |
def get_alpha(self, x: int, y: int) -> int: | return lib.TCOD_image_get_alpha(self.image_c, x, y)<EOL> | Get the Image alpha of the pixel at x, y.
Args:
x (int): X pixel of the image. Starting from the left at 0.
y (int): Y pixel of the image. Starting from the top at 0.
Returns:
int: The alpha value of the pixel.
With 0 being fully transparent and 255 being fully opaque. | f3106:c1:m9 |
def refresh_console(self, console: tcod.console.Console) -> None: | lib.TCOD_image_refresh_console(self.image_c, _console(console))<EOL> | 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. | f3106:c1:m10 |
def _get_size(self) -> Tuple[int, int]: | w = ffi.new("<STR_LIT>")<EOL>h = ffi.new("<STR_LIT>")<EOL>lib.TCOD_image_get_size(self.image_c, w, h)<EOL>return w[<NUM_LIT:0>], h[<NUM_LIT:0>]<EOL> | Return the (width, height) for this Image.
Returns:
Tuple[int, int]: The (width, height) of this Image | f3106:c1:m11 |
def get_pixel(self, x: int, y: int) -> Tuple[int, int, int]: | color = lib.TCOD_image_get_pixel(self.image_c, x, y)<EOL>return color.r, color.g, color.b<EOL> | Get the color of a pixel in this Image.
Args:
x (int): X pixel of the Image. Starting from the left at 0.
y (int): Y pixel of the Image. Starting from the top at 0.
Returns:
Tuple[int, int, int]:
An (r, g, b) tuple containing the pixels color value.
Values are in a 0 to 255 range. | f3106:c1:m12 |
def get_mipmap_pixel(<EOL>self, left: float, top: float, right: float, bottom: float<EOL>) -> Tuple[int, int, int]: | color = lib.TCOD_image_get_mipmap_pixel(<EOL>self.image_c, left, top, right, bottom<EOL>)<EOL>return (color.r, color.g, color.b)<EOL> | Get the average color of a rectangle in this Image.
Parameters should stay within the following limits:
* 0 <= left < right < Image.width
* 0 <= top < bottom < Image.height
Args:
left (float): Left corner of the region.
top (float): Top corner of the region.
right (float): Right corner of the region.
bottom (float): Bottom corner of the region.
Returns:
Tuple[int, int, int]:
An (r, g, b) tuple containing the averaged color value.
Values are in a 0 to 255 range. | f3106:c1:m13 |
def put_pixel(self, x: int, y: int, color: Tuple[int, int, int]) -> None: | lib.TCOD_image_put_pixel(self.image_c, x, y, color)<EOL> | Change a pixel on this Image.
Args:
x (int): X pixel of the Image. Starting from the left at 0.
y (int): Y pixel of the Image. Starting from the top at 0.
color (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance. | f3106:c1:m14 |
def blit(<EOL>self,<EOL>console: tcod.console.Console,<EOL>x: float,<EOL>y: float,<EOL>bg_blend: int,<EOL>scale_x: float,<EOL>scale_y: float,<EOL>angle: float,<EOL>) -> None: | lib.TCOD_image_blit(<EOL>self.image_c,<EOL>_console(console),<EOL>x,<EOL>y,<EOL>bg_blend,<EOL>scale_x,<EOL>scale_y,<EOL>angle,<EOL>)<EOL> | 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?) | f3106:c1:m15 |
def blit_rect(<EOL>self,<EOL>console: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>bg_blend: int,<EOL>) -> None: | lib.TCOD_image_blit_rect(<EOL>self.image_c, _console(console), x, y, width, height, bg_blend<EOL>)<EOL> | 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. | f3106:c1:m16 |
def blit_2x(<EOL>self,<EOL>console: tcod.console.Console,<EOL>dest_x: int,<EOL>dest_y: int,<EOL>img_x: int = <NUM_LIT:0>,<EOL>img_y: int = <NUM_LIT:0>,<EOL>img_width: int = -<NUM_LIT:1>,<EOL>img_height: int = -<NUM_LIT:1>,<EOL>) -> None: | lib.TCOD_image_blit_2x(<EOL>self.image_c,<EOL>_console(console),<EOL>dest_x,<EOL>dest_y,<EOL>img_x,<EOL>img_y,<EOL>img_width,<EOL>img_height,<EOL>)<EOL> | 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. | f3106:c1:m17 |
def save_as(self, filename: str) -> None: | lib.TCOD_image_save(self.image_c, filename.encode("<STR_LIT:utf-8>"))<EOL> | Save the Image to a 32-bit .bmp or .png file.
Args:
filename (Text): File path to same this Image. | f3106:c1:m18 |
def _fmt(string: str) -> bytes: | return string.encode("<STR_LIT:utf-8>").replace(b"<STR_LIT:%>", b"<STR_LIT>")<EOL> | Return a string that escapes 'C printf' side effects. | f3107:m0 |
def get_height_rect(width: int, string: str) -> int: | string_ = string.encode("<STR_LIT:utf-8>") <EOL>return int(lib.get_height_rect2(width, string_, len(string_)))<EOL> | Return the number of lines which would be printed from these parameters.
`width` is the width of the print boundary.
`string` is a Unicode string which may include color control characters.
.. versionadded:: 9.2 | f3107:m1 |
@classmethod<EOL><INDENT>def _from_cdata(cls, cdata: Any, order: str = "<STR_LIT:C>") -> "<STR_LIT>":<DEDENT> | if isinstance(cdata, cls):<EOL><INDENT>return cdata<EOL><DEDENT>self = object.__new__(cls) <EOL>self.console_c = cdata<EOL>self._init_setup_console_data(order)<EOL>return self<EOL> | Return a Console instance which wraps this `TCOD_Console*` object. | f3107:c0:m1 |
@classmethod<EOL><INDENT>def _get_root(cls, order: Optional[str] = None) -> "<STR_LIT>":<DEDENT> | global _root_console<EOL>if _root_console is None:<EOL><INDENT>_root_console = object.__new__(cls)<EOL><DEDENT>self = _root_console <EOL>if order is not None:<EOL><INDENT>self._order = order<EOL><DEDENT>self.console_c = ffi.NULL<EOL>self._init_setup_console_data(self._order)<EOL>return self<EOL> | Return a root console singleton with valid buffers.
This function will also update an already active root console. | f3107:c0:m2 |
def _init_setup_console_data(self, order: str = "<STR_LIT:C>") -> None: | global _root_console<EOL>self._key_color = None<EOL>if self.console_c == ffi.NULL:<EOL><INDENT>_root_console = self<EOL>self._console_data = lib.TCOD_ctx.root<EOL><DEDENT>else:<EOL><INDENT>self._console_data = ffi.cast(<EOL>"<STR_LIT>", self.console_c<EOL>)<EOL><DEDENT>self._tiles = np.frombuffer(<EOL>ffi.buffer(self._console_data.tiles[<NUM_LIT:0> : self.width * self.height]),<EOL>dtype=self.DTYPE,<EOL>).reshape((self.height, self.width))<EOL>self._order = tcod._internal.verify_order(order)<EOL> | Setup numpy arrays over libtcod data buffers. | f3107:c0:m3 |
@property<EOL><INDENT>def width(self) -> int:<DEDENT> | return lib.TCOD_console_get_width(self.console_c)<EOL> | int: The width of this Console. (read-only) | f3107:c0:m4 |
@property<EOL><INDENT>def height(self) -> int:<DEDENT> | return lib.TCOD_console_get_height(self.console_c)<EOL> | int: The height of this Console. (read-only) | f3107:c0:m5 |
@property<EOL><INDENT>def bg(self) -> np.array:<DEDENT> | bg = self._tiles["<STR_LIT>"][..., :<NUM_LIT:3>]<EOL>if self._order == "<STR_LIT:F>":<EOL><INDENT>bg = bg.transpose(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:2>)<EOL><DEDENT>return bg<EOL> | A uint8 array with the shape (height, width, 3).
You can change the consoles background colors by using this array.
Index this array with ``console.bg[i, j, channel] # order='C'`` or
``console.bg[x, y, channel] # order='F'``. | f3107:c0:m6 |
@property<EOL><INDENT>def fg(self) -> np.array:<DEDENT> | fg = self._tiles["<STR_LIT>"][..., :<NUM_LIT:3>]<EOL>if self._order == "<STR_LIT:F>":<EOL><INDENT>fg = fg.transpose(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:2>)<EOL><DEDENT>return fg<EOL> | A uint8 array with the shape (height, width, 3).
You can change the consoles foreground colors by using this array.
Index this array with ``console.fg[i, j, channel] # order='C'`` or
``console.fg[x, y, channel] # order='F'``. | f3107:c0:m7 |
@property<EOL><INDENT>def ch(self) -> np.array:<DEDENT> | return self._tiles["<STR_LIT>"].T if self._order == "<STR_LIT:F>" else self._tiles["<STR_LIT>"]<EOL> | An integer array with the shape (height, width).
You can change the consoles character codes by using this array.
Index this array with ``console.ch[i, j] # order='C'`` or
``console.ch[x, y] # order='F'``. | f3107:c0:m8 |
@property<EOL><INDENT>def tiles(self) -> np.array:<DEDENT> | return self._tiles.T if self._order == "<STR_LIT:F>" else self._tiles<EOL> | An array of this consoles tile data.
This acts as a combination of the `ch`, `fg`, and `bg` attributes.
Colors include an alpha channel but how alpha works is currently
undefined.
Example::
>>> con = tcod.console.Console(10, 2, order="F")
>>> con.tiles[0, 0] = (
... ord("X"),
... (*tcod.white, 255),
... (*tcod.black, 255),
... )
>>> con.tiles[0, 0]
(88, [255, 255, 255, 255], [ 0, 0, 0, 255])
.. versionadded:: 10.0 | f3107:c0:m9 |
@property<EOL><INDENT>def default_bg(self) -> Tuple[int, int, int]:<DEDENT> | color = self._console_data.back<EOL>return color.r, color.g, color.b<EOL> | Tuple[int, int, int]: The default background color. | f3107:c0:m10 |
@property<EOL><INDENT>def default_fg(self) -> Tuple[int, int, int]:<DEDENT> | color = self._console_data.fore<EOL>return color.r, color.g, color.b<EOL> | Tuple[int, int, int]: The default foreground color. | f3107:c0:m12 |
@property<EOL><INDENT>def default_bg_blend(self) -> int:<DEDENT> | return self._console_data.bkgnd_flag<EOL> | int: The default blending mode. | f3107:c0:m14 |
@property<EOL><INDENT>def default_alignment(self) -> int:<DEDENT> | return self._console_data.alignment<EOL> | int: The default text alignment. | f3107:c0:m16 |
def __clear_warning(self, name: str, value: Tuple[int, int, int]) -> None: | warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (name, value),<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:3>,<EOL>)<EOL> | Raise a warning for bad default values during calls to clear. | f3107:c0:m18 |
def clear( <EOL>self,<EOL>ch: int = ord("<STR_LIT:U+0020>"),<EOL>fg: Tuple[int, int, int] = ...,<EOL>bg: Tuple[int, int, int] = ...,<EOL>) -> None: | if fg is ...:<EOL><INDENT>fg = self.default_fg<EOL>if fg != (<NUM_LIT:255>, <NUM_LIT:255>, <NUM_LIT:255>):<EOL><INDENT>self.__clear_warning("<STR_LIT>", fg)<EOL><DEDENT><DEDENT>if bg is ...:<EOL><INDENT>bg = self.default_bg<EOL>if bg != (<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>):<EOL><INDENT>self.__clear_warning("<STR_LIT>", bg)<EOL><DEDENT><DEDENT>self._tiles[...] = ch, (*fg, <NUM_LIT:255>), (*bg, <NUM_LIT:255>)<EOL> | Reset all values in this console to a single value.
`ch` is the character to clear the console with. Defaults to the space
character.
`fg` and `bg` are the colors to clear the console with. Defaults to
white-on-black if the console defaults are untouched.
.. note::
If `fg`/`bg` are not set, they will default to
:any:`default_fg`/:any:`default_bg`.
However, default values other than white-on-back are deprecated.
.. versionchanged:: 8.5
Added the `ch`, `fg`, and `bg` parameters.
Non-white-on-black default values are deprecated. | f3107:c0:m19 |
def put_char(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>ch: int,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>) -> None: | lib.TCOD_console_put_char(self.console_c, x, y, ch, bg_blend)<EOL> | Draw the character c at x,y using the default colors and a blend mode.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
ch (int): Character code to draw. Must be in integer form.
bg_blend (int): Blending mode to use, defaults to BKGND_DEFAULT. | f3107:c0:m20 |
def __deprecate_defaults(<EOL>self,<EOL>new_func: str,<EOL>bg_blend: Any,<EOL>alignment: Any = ...,<EOL>clear: Any = ...,<EOL>) -> None: | if not __debug__:<EOL><INDENT>return<EOL><DEDENT>fg = self.default_fg <EOL>bg = self.default_bg <EOL>if bg_blend == tcod.constants.BKGND_NONE:<EOL><INDENT>bg = None<EOL><DEDENT>if bg_blend == tcod.constants.BKGND_DEFAULT:<EOL><INDENT>bg_blend = self.default_bg_blend<EOL><DEDENT>else:<EOL><INDENT>bg_blend = None<EOL><DEDENT>if bg_blend == tcod.constants.BKGND_NONE:<EOL><INDENT>bg = None<EOL>bg_blend = None<EOL><DEDENT>if bg_blend == tcod.constants.BKGND_SET:<EOL><INDENT>bg_blend = None<EOL><DEDENT>if alignment is None:<EOL><INDENT>alignment = self.default_alignment<EOL>if alignment == tcod.constants.LEFT:<EOL><INDENT>alignment = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>alignment = None<EOL><DEDENT>if clear is not ...:<EOL><INDENT>fg = None<EOL><DEDENT>params = []<EOL>if clear is True:<EOL><INDENT>params.append('<STR_LIT>')<EOL><DEDENT>if clear is False:<EOL><INDENT>params.append("<STR_LIT>")<EOL><DEDENT>if fg is not None:<EOL><INDENT>params.append("<STR_LIT>" % (fg,))<EOL><DEDENT>if bg is not None:<EOL><INDENT>params.append("<STR_LIT>" % (bg,))<EOL><DEDENT>if bg_blend is not None:<EOL><INDENT>params.append("<STR_LIT>" % (self.__BG_BLEND_LOOKUP[bg_blend],))<EOL><DEDENT>if alignment is not None:<EOL><INDENT>params.append(<EOL>"<STR_LIT>" % (self.__ALIGNMENT_LOOKUP[alignment],)<EOL>)<EOL><DEDENT>param_str = "<STR_LIT:U+002CU+0020>".join(params)<EOL>if not param_str:<EOL><INDENT>param_str = "<STR_LIT:.>"<EOL><DEDENT>else:<EOL><INDENT>param_str = "<STR_LIT>" % (param_str,)<EOL><DEDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (new_func, param_str),<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:3>,<EOL>)<EOL> | Return the parameters needed to recreate the current default state. | f3107:c0:m21 |
def print_(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>string: str,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>alignment: Optional[int] = None,<EOL>) -> None: | self.__deprecate_defaults("<STR_LIT>", bg_blend, alignment)<EOL>alignment = self.default_alignment if alignment is None else alignment<EOL>lib.TCOD_console_printf_ex(<EOL>self.console_c, x, y, bg_blend, alignment, _fmt(string)<EOL>)<EOL> | Print a color formatted string on a console.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
string (str): A Unicode string optionally using color codes.
bg_blend (int): Blending mode to use, defaults to BKGND_DEFAULT.
alignment (Optional[int]): Text alignment.
.. deprecated:: 8.5
Console methods which depend on console defaults have been
deprecated.
Use :any:`Console.print` instead, calling this function will print
a warning detailing which default values need to be made explicit. | f3107:c0:m22 |
def print_rect(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>string: str,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>alignment: Optional[int] = None,<EOL>) -> int: | self.__deprecate_defaults("<STR_LIT>", bg_blend, alignment)<EOL>alignment = self.default_alignment if alignment is None else alignment<EOL>return int(<EOL>lib.TCOD_console_printf_rect_ex(<EOL>self.console_c,<EOL>x,<EOL>y,<EOL>width,<EOL>height,<EOL>bg_blend,<EOL>alignment,<EOL>_fmt(string),<EOL>)<EOL>)<EOL> | Print a string constrained to a rectangle.
If h > 0 and the bottom of the rectangle is reached,
the string is truncated. If h = 0,
the string is only truncated if it reaches the bottom of the console.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
width (int): Maximum width to render the text.
height (int): Maximum lines to render the text.
string (str): A Unicode string.
bg_blend (int): Background blending flag.
alignment (Optional[int]): Alignment flag.
Returns:
int: The number of lines of text once word-wrapped.
.. deprecated:: 8.5
Console methods which depend on console defaults have been
deprecated.
Use :any:`Console.print_box` instead, calling this function will
print a warning detailing which default values need to be made
explicit. | f3107:c0:m23 |
def get_height_rect(<EOL>self, x: int, y: int, width: int, height: int, string: str<EOL>) -> int: | string_ = string.encode("<STR_LIT:utf-8>")<EOL>return int(<EOL>lib.get_height_rect(<EOL>self.console_c, x, y, width, height, string_, len(string_)<EOL>)<EOL>)<EOL> | Return the height of this text word-wrapped into this rectangle.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
width (int): Maximum width to render the text.
height (int): Maximum lines to render the text.
string (str): A Unicode string.
Returns:
int: The number of lines of text once word-wrapped. | f3107:c0:m24 |
def rect(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>clear: bool,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>) -> None: | self.__deprecate_defaults("<STR_LIT>", bg_blend, clear=bool(clear))<EOL>lib.TCOD_console_rect(<EOL>self.console_c, x, y, width, height, clear, bg_blend<EOL>)<EOL> | Draw a the background color on a rect optionally clearing the text.
If `clear` is True the affected tiles are changed to space character.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
width (int): Maximum width to render the text.
height (int): Maximum lines to render the text.
clear (bool): If True all text in the affected area will be
removed.
bg_blend (int): Background blending flag.
.. deprecated:: 8.5
Console methods which depend on console defaults have been
deprecated.
Use :any:`Console.draw_rect` instead, calling this function will
print a warning detailing which default values need to be made
explicit. | f3107:c0:m25 |
def hline(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>) -> None: | self.__deprecate_defaults("<STR_LIT>", bg_blend)<EOL>lib.TCOD_console_hline(self.console_c, x, y, width, bg_blend)<EOL> | Draw a horizontal line on the console.
This always uses ord('─'), the horizontal line character.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
width (int): The horizontal length of this line.
bg_blend (int): The background blending flag.
.. deprecated:: 8.5
Console methods which depend on console defaults have been
deprecated.
Use :any:`Console.draw_rect` instead, calling this function will
print a warning detailing which default values need to be made
explicit. | f3107:c0:m26 |
def vline(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>height: int,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>) -> None: | self.__deprecate_defaults("<STR_LIT>", bg_blend)<EOL>lib.TCOD_console_vline(self.console_c, x, y, height, bg_blend)<EOL> | Draw a vertical line on the console.
This always uses ord('│'), the vertical line character.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
height (int): The horozontal length of this line.
bg_blend (int): The background blending flag.
.. deprecated:: 8.5
Console methods which depend on console defaults have been
deprecated.
Use :any:`Console.draw_rect` instead, calling this function will
print a warning detailing which default values need to be made
explicit. | f3107:c0:m27 |
def print_frame(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>string: str = "<STR_LIT>",<EOL>clear: bool = True,<EOL>bg_blend: int = tcod.constants.BKGND_DEFAULT,<EOL>) -> None: | self.__deprecate_defaults("<STR_LIT>", bg_blend)<EOL>string = _fmt(string) if string else ffi.NULL<EOL>lib.TCOD_console_printf_frame(<EOL>self.console_c, x, y, width, height, clear, bg_blend, string<EOL>)<EOL> | Draw a framed rectangle with optional text.
This uses the default background color and blend mode to fill the
rectangle and the default foreground to draw the outline.
`string` will be printed on the inside of the rectangle, word-wrapped.
If `string` is empty then no title will be drawn.
Args:
x (int): The x coordinate from the left.
y (int): The y coordinate from the top.
width (int): The width if the frame.
height (int): The height of the frame.
string (str): A Unicode string to print.
clear (bool): If True all text in the affected area will be
removed.
bg_blend (int): The background blending flag.
.. versionchanged:: 8.2
Now supports Unicode strings.
.. deprecated:: 8.5
Console methods which depend on console defaults have been
deprecated.
Use :any:`Console.draw_frame` instead, calling this function will
print a warning detailing which default values need to be made
explicit. | f3107:c0:m28 |
def blit(<EOL>self,<EOL>dest: "<STR_LIT>",<EOL>dest_x: int = <NUM_LIT:0>,<EOL>dest_y: int = <NUM_LIT:0>,<EOL>src_x: int = <NUM_LIT:0>,<EOL>src_y: int = <NUM_LIT:0>,<EOL>width: int = <NUM_LIT:0>,<EOL>height: int = <NUM_LIT:0>,<EOL>fg_alpha: float = <NUM_LIT:1.0>,<EOL>bg_alpha: float = <NUM_LIT:1.0>,<EOL>key_color: Optional[Tuple[int, int, int]] = None,<EOL>) -> None: | <EOL>if hasattr(src_y, "<STR_LIT>"):<EOL><INDENT>(<EOL>src_x, <EOL>src_y,<EOL>width,<EOL>height,<EOL>dest, <EOL>dest_x,<EOL>dest_y,<EOL>) = (dest, dest_x, dest_y, src_x, src_y, width, height)<EOL>warnings.warn(<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL><DEDENT>key_color = key_color or self._key_color<EOL>if key_color:<EOL><INDENT>key_color = ffi.new("<STR_LIT>", key_color)<EOL>lib.TCOD_console_blit_key_color(<EOL>self.console_c,<EOL>src_x,<EOL>src_y,<EOL>width,<EOL>height,<EOL>dest.console_c,<EOL>dest_x,<EOL>dest_y,<EOL>fg_alpha,<EOL>bg_alpha,<EOL>key_color,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>lib.TCOD_console_blit(<EOL>self.console_c,<EOL>src_x,<EOL>src_y,<EOL>width,<EOL>height,<EOL>dest.console_c,<EOL>dest_x,<EOL>dest_y,<EOL>fg_alpha,<EOL>bg_alpha,<EOL>)<EOL><DEDENT> | Blit from this console onto the ``dest`` console.
Args:
dest (Console): The destintaion console to blit onto.
dest_x (int): Leftmost coordinate of the destintaion console.
dest_y (int): Topmost coordinate of the destintaion console.
src_x (int): X coordinate from this console to blit, from the left.
src_y (int): Y coordinate from this console to blit, from the top.
width (int): The width of the region to blit.
If this is 0 the maximum possible width will be used.
height (int): The height of the region to blit.
If this is 0 the maximum possible height will be used.
fg_alpha (float): Foreground color alpha vaule.
bg_alpha (float): Background color alpha vaule.
key_color (Optional[Tuple[int, int, int]]):
None, or a (red, green, blue) tuple with values of 0-255.
.. versionchanged:: 4.0
Parameters were rearraged and made optional.
Previously they were:
`(x, y, width, height, dest, dest_x, dest_y, *)` | f3107:c0:m29 |
@deprecate(<EOL>"<STR_LIT>"<EOL>)<EOL><INDENT>def set_key_color(self, color: Optional[Tuple[int, int, int]]) -> None:<DEDENT> | self._key_color = color<EOL> | Set a consoles blit transparent color.
`color` is the (r, g, b) color, or None to disable key color.
.. deprecated:: 8.5
Pass the key color to :any:`Console.blit` instead of calling this
function. | f3107:c0:m30 |
def __enter__(self) -> "<STR_LIT>": | if self.console_c != ffi.NULL:<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>return self<EOL> | Returns this console in a managed context.
When the root console is used as a context, the graphical window will
close once the context is left as if :any:`tcod.console_delete` was
called on it.
This is useful for some Python IDE's like IDLE, where the window would
not be closed on its own otherwise. | f3107:c0:m31 |
def __exit__(self, *args: Any) -> None: | lib.TCOD_console_delete(self.console_c)<EOL> | Closes the graphical window on exit.
Some tcod functions may have undefined behaviour after this point. | f3107:c0:m32 |
def __bool__(self) -> bool: | return bool(self.console_c != ffi.NULL)<EOL> | Returns False if this is the root console.
This mimics libtcodpy behaviour. | f3107:c0:m33 |
def __repr__(self) -> str: | return (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% (self.width, self.height, self._order, self.tiles)<EOL>)<EOL> | Return a string representation of this console. | f3107:c0:m36 |
def __str__(self) -> str: | return "<STR_LIT>" % "<STR_LIT>".join(<EOL>"<STR_LIT>".join(chr(c) for c in line) for line in self._tiles["<STR_LIT>"]<EOL>)<EOL> | Return a simplified representation of this consoles contents. | f3107:c0:m37 |
def print(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>string: str,<EOL>fg: Optional[Tuple[int, int, int]] = None,<EOL>bg: Optional[Tuple[int, int, int]] = None,<EOL>bg_blend: int = tcod.constants.BKGND_SET,<EOL>alignment: int = tcod.constants.LEFT,<EOL>) -> None: | x, y = self._pythonic_index(x, y)<EOL>string_ = string.encode("<STR_LIT:utf-8>") <EOL>lib.console_print(<EOL>self.console_c,<EOL>x,<EOL>y,<EOL>string_,<EOL>len(string_),<EOL>(fg,) if fg is not None else ffi.NULL,<EOL>(bg,) if bg is not None else ffi.NULL,<EOL>bg_blend,<EOL>alignment,<EOL>)<EOL> | Print a string on a console with manual line breaks.
`x` and `y` are the starting tile, with ``0,0`` as the upper-left
corner of the console. You can use negative numbers if you want to
start printing relative to the bottom-right corner, but this behavior
may change in future versions.
`string` is a Unicode string which may include color control
characters. Strings which are too long will be truncated until the
next newline character ``"\\n"``.
`fg` and `bg` are the foreground text color and background tile color
respectfully. This is a 3-item tuple with (r, g, b) color values from
0 to 255. These parameters can also be set to `None` to leave the
colors unchanged.
`bg_blend` is the blend type used by libtcod.
`alignment` can be `tcod.LEFT`, `tcod.CENTER`, or `tcod.RIGHT`.
.. versionadded:: 8.5
.. versionchanged:: 9.0
`fg` and `bg` now default to `None` instead of white-on-black. | f3107:c0:m39 |
def print_box(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>string: str,<EOL>fg: Optional[Tuple[int, int, int]] = None,<EOL>bg: Optional[Tuple[int, int, int]] = None,<EOL>bg_blend: int = tcod.constants.BKGND_SET,<EOL>alignment: int = tcod.constants.LEFT,<EOL>) -> int: | x, y = self._pythonic_index(x, y)<EOL>string_ = string.encode("<STR_LIT:utf-8>") <EOL>return int(<EOL>lib.print_rect(<EOL>self.console_c,<EOL>x,<EOL>y,<EOL>width,<EOL>height,<EOL>string_,<EOL>len(string_),<EOL>(fg,) if fg is not None else ffi.NULL,<EOL>(bg,) if bg is not None else ffi.NULL,<EOL>bg_blend,<EOL>alignment,<EOL>)<EOL>)<EOL> | Print a string constrained to a rectangle and return the height.
`x` and `y` are the starting tile, with ``0,0`` as the upper-left
corner of the console. You can use negative numbers if you want to
start printing relative to the bottom-right corner, but this behavior
may change in future versions.
`width` and `height` determine the bounds of the rectangle, the text
will automatically be broken to fit within these bounds.
`string` is a Unicode string which may include color control
characters.
`fg` and `bg` are the foreground text color and background tile color
respectfully. This is a 3-item tuple with (r, g, b) color values from
0 to 255. These parameters can also be set to `None` to leave the
colors unchanged.
`bg_blend` is the blend type used by libtcod.
`alignment` can be `tcod.LEFT`, `tcod.CENTER`, or `tcod.RIGHT`.
Returns the actual height of the printed area.
.. versionadded:: 8.5
.. versionchanged:: 9.0
`fg` and `bg` now default to `None` instead of white-on-black. | f3107:c0:m40 |
def draw_frame(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>title: str = "<STR_LIT>",<EOL>clear: bool = True,<EOL>fg: Optional[Tuple[int, int, int]] = None,<EOL>bg: Optional[Tuple[int, int, int]] = None,<EOL>bg_blend: int = tcod.constants.BKGND_SET,<EOL>) -> None: | x, y = self._pythonic_index(x, y)<EOL>title_ = title.encode("<STR_LIT:utf-8>") <EOL>lib.print_frame(<EOL>self.console_c,<EOL>x,<EOL>y,<EOL>width,<EOL>height,<EOL>title_,<EOL>len(title_),<EOL>(fg,) if fg is not None else ffi.NULL,<EOL>(bg,) if bg is not None else ffi.NULL,<EOL>bg_blend,<EOL>clear,<EOL>)<EOL> | Draw a framed rectangle with an optional title.
`x` and `y` are the starting tile, with ``0,0`` as the upper-left
corner of the console. You can use negative numbers if you want to
start printing relative to the bottom-right corner, but this behavior
may change in future versions.
`width` and `height` determine the size of the frame.
`title` is a Unicode string.
If `clear` is True than the region inside of the frame will be cleared.
`fg` and `bg` are the foreground text color and background tile color
respectfully. This is a 3-item tuple with (r, g, b) color values from
0 to 255. These parameters can also be set to `None` to leave the
colors unchanged.
`bg_blend` is the blend type used by libtcod.
.. versionadded:: 8.5
.. versionchanged:: 9.0
`fg` and `bg` now default to `None` instead of white-on-black. | f3107:c0:m41 |
def draw_rect(<EOL>self,<EOL>x: int,<EOL>y: int,<EOL>width: int,<EOL>height: int,<EOL>ch: int,<EOL>fg: Optional[Tuple[int, int, int]] = None,<EOL>bg: Optional[Tuple[int, int, int]] = None,<EOL>bg_blend: int = tcod.constants.BKGND_SET,<EOL>) -> None: | x, y = self._pythonic_index(x, y)<EOL>lib.draw_rect(<EOL>self.console_c,<EOL>x,<EOL>y,<EOL>width,<EOL>height,<EOL>ch,<EOL>(fg,) if fg is not None else ffi.NULL,<EOL>(bg,) if bg is not None else ffi.NULL,<EOL>bg_blend,<EOL>)<EOL> | Draw characters and colors over a rectangular region.
`x` and `y` are the starting tile, with ``0,0`` as the upper-left
corner of the console. You can use negative numbers if you want to
start printing relative to the bottom-right corner, but this behavior
may change in future versions.
`width` and `height` determine the size of the rectangle.
`ch` is a Unicode integer. You can use 0 to leave the current
characters unchanged.
`fg` and `bg` are the foreground text color and background tile color
respectfully. This is a 3-item tuple with (r, g, b) color values from
0 to 255. These parameters can also be set to `None` to leave the
colors unchanged.
`bg_blend` is the blend type used by libtcod.
.. versionadded:: 8.5
.. versionchanged:: 9.0
`fg` and `bg` now default to `None` instead of white-on-black. | f3107:c0:m42 |
def _int(int_or_str: Any) -> int: | if isinstance(int_or_str, str):<EOL><INDENT>return ord(int_or_str)<EOL><DEDENT>if isinstance(int_or_str, bytes):<EOL><INDENT>return int_or_str[<NUM_LIT:0>]<EOL><DEDENT>return int(int_or_str)<EOL> | return an integer where a single character string may be expected | f3109:m1 |
def _console(console: Any) -> Any: | try:<EOL><INDENT>return console.console_c<EOL><DEDENT>except AttributeError:<EOL><INDENT>warnings.warn(<EOL>(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>),<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:3>,<EOL>)<EOL>return ffi.NULL<EOL><DEDENT> | Return a cffi console. | f3109:m5 |
def propagate(self, *exc_info: Any) -> None: | if not self.exc_info:<EOL><INDENT>self.exc_info = exc_info<EOL><DEDENT> | set an exception to be raised once this context exits
if multiple errors are caught, only keep the first exception raised | f3109:c0:m1 |
def __enter__(self) -> Callable[[Any], None]: | return self.propagate<EOL> | once in context, only the propagate call is needed to use this
class effectively | f3109:c0:m2 |
def __exit__(self, type: Any, value: Any, traceback: Any) -> None: | if self.exc_info:<EOL><INDENT>type, value, traceback = self.exc_info<EOL>self.exc_info = None<EOL><DEDENT>if type:<EOL><INDENT>exception = type(value)<EOL>exception.__traceback__ = traceback<EOL>raise exception<EOL><DEDENT> | if we're holding on to an exception, raise it now
prefers our held exception over any current raising error
self.exc_info is reset now in case of nested manager shenanigans | f3109:c0:m3 |
def __str__(self) -> str: | status = "<STR_LIT>"<EOL>if self.children:<EOL><INDENT>status = "<STR_LIT>" % (<EOL>self.position,<EOL>self.horizontal,<EOL>)<EOL><DEDENT>return "<STR_LIT>" % (<EOL>self.__class__.__name__,<EOL>self.x,<EOL>self.y,<EOL>self.width,<EOL>self.height,<EOL>self.level,<EOL>status,<EOL>)<EOL> | Provide a useful readout when printed. | f3111:c0:m6 |
def split_once(self, horizontal: bool, position: int) -> None: | cdata = self._as_cdata()<EOL>lib.TCOD_bsp_split_once(cdata, horizontal, position)<EOL>self._unpack_bsp_tree(cdata)<EOL> | Split this partition into 2 sub-partitions.
Args:
horizontal (bool):
position (int): | f3111:c0:m8 |
def split_recursive(<EOL>self,<EOL>depth: int,<EOL>min_width: int,<EOL>min_height: int,<EOL>max_horizontal_ratio: float,<EOL>max_vertical_ratio: float,<EOL>seed: Optional[tcod.random.Random] = None,<EOL>) -> None: | cdata = self._as_cdata()<EOL>lib.TCOD_bsp_split_recursive(<EOL>cdata,<EOL>seed or ffi.NULL,<EOL>depth,<EOL>min_width,<EOL>min_height,<EOL>max_horizontal_ratio,<EOL>max_vertical_ratio,<EOL>)<EOL>self._unpack_bsp_tree(cdata)<EOL> | Divide this partition recursively.
Args:
depth (int): The maximum depth to divide this object recursively.
min_width (int): The minimum width of any individual partition.
min_height (int): The minimum height of any individual partition.
max_horizontal_ratio (float):
Prevent creating a horizontal ratio more extreme than this.
max_vertical_ratio (float):
Prevent creating a vertical ratio more extreme than this.
seed (Optional[tcod.random.Random]):
The random number generator to use. | f3111:c0:m9 |
@deprecate("<STR_LIT>")<EOL><INDENT>def walk(self) -> Iterator["<STR_LIT>"]:<DEDENT> | return self.post_order()<EOL> | Iterate over this BSP's hierarchy in pre order.
.. deprecated:: 2.3
Use :any:`pre_order` instead. | f3111:c0:m10 |
def pre_order(self) -> Iterator["<STR_LIT>"]: | yield self<EOL>for child in self.children:<EOL><INDENT>yield from child.pre_order()<EOL><DEDENT> | Iterate over this BSP's hierarchy in pre order.
.. versionadded:: 8.3 | f3111:c0:m11 |
def in_order(self) -> Iterator["<STR_LIT>"]: | if self.children:<EOL><INDENT>yield from self.children[<NUM_LIT:0>].in_order()<EOL>yield self<EOL>yield from self.children[<NUM_LIT:1>].in_order()<EOL><DEDENT>else:<EOL><INDENT>yield self<EOL><DEDENT> | Iterate over this BSP's hierarchy in order.
.. versionadded:: 8.3 | f3111:c0:m12 |
def post_order(self) -> Iterator["<STR_LIT>"]: | for child in self.children:<EOL><INDENT>yield from child.post_order()<EOL><DEDENT>yield self<EOL> | Iterate over this BSP's hierarchy in post order.
.. versionadded:: 8.3 | f3111:c0:m13 |
def level_order(self) -> Iterator["<STR_LIT>"]: | next = [self] <EOL>while next:<EOL><INDENT>level = next <EOL>next = []<EOL>yield from level<EOL>for node in level:<EOL><INDENT>next.extend(node.children)<EOL><DEDENT><DEDENT> | Iterate over this BSP's hierarchy in level order.
.. versionadded:: 8.3 | f3111:c0:m14 |
def inverted_level_order(self) -> Iterator["<STR_LIT>"]: | levels = [] <EOL>next = [self] <EOL>while next:<EOL><INDENT>levels.append(next)<EOL>level = next <EOL>next = []<EOL>for node in level:<EOL><INDENT>next.extend(node.children)<EOL><DEDENT><DEDENT>while levels:<EOL><INDENT>yield from levels.pop()<EOL><DEDENT> | Iterate over this BSP's hierarchy in inverse level order.
.. versionadded:: 8.3 | f3111:c0:m15 |
def contains(self, x: int, y: int) -> bool: | return (<EOL>self.x <= x < self.x + self.width<EOL>and self.y <= y < self.y + self.height<EOL>)<EOL> | Returns True if this node contains these coordinates.
Args:
x (int): X position to check.
y (int): Y position to check.
Returns:
bool: True if this node contains these coordinates.
Otherwise False. | f3111:c0:m16 |
def find_node(self, x: int, y: int) -> Optional["<STR_LIT>"]: | if not self.contains(x, y):<EOL><INDENT>return None<EOL><DEDENT>for child in self.children:<EOL><INDENT>found = child.find_node(x, y) <EOL>if found:<EOL><INDENT>return found<EOL><DEDENT><DEDENT>return self<EOL> | Return the deepest node which contains these coordinates.
Returns:
Optional[BSP]: BSP object or None. | f3111:c0:m17 |
@deprecate("<STR_LIT>")<EOL>def bsp_new_with_size(x: int, y: int, w: int, h: int) -> tcod.bsp.BSP: | return Bsp(x, y, w, h)<EOL> | Create a new BSP instance with the given rectangle.
Args:
x (int): Rectangle left coordinate.
y (int): Rectangle top coordinate.
w (int): Rectangle width.
h (int): Rectangle height.
Returns:
BSP: A new BSP instance.
.. deprecated:: 2.0
Call the :any:`BSP` class instead. | f3112:m3 |
@deprecate("<STR_LIT>")<EOL>def bsp_split_once(<EOL>node: tcod.bsp.BSP, horizontal: bool, position: int<EOL>) -> None: | node.split_once(horizontal, position)<EOL> | .. deprecated:: 2.0
Use :any:`BSP.split_once` instead. | f3112:m4 |
@deprecate("<STR_LIT>")<EOL>def bsp_split_recursive(<EOL>node: tcod.bsp.BSP,<EOL>randomizer: Optional[tcod.random.Random],<EOL>nb: int,<EOL>minHSize: int,<EOL>minVSize: int,<EOL>maxHRatio: int,<EOL>maxVRatio: int,<EOL>) -> None: | node.split_recursive(<EOL>nb, minHSize, minVSize, maxHRatio, maxVRatio, randomizer<EOL>)<EOL> | .. deprecated:: 2.0
Use :any:`BSP.split_recursive` instead. | f3112:m5 |
@deprecate("<STR_LIT>")<EOL>def bsp_resize(node: tcod.bsp.BSP, x: int, y: int, w: int, h: int) -> None: | node.x = x<EOL>node.y = y<EOL>node.width = w<EOL>node.height = h<EOL> | .. deprecated:: 2.0
Assign directly to :any:`BSP` attributes instead. | f3112:m6 |
@deprecate("<STR_LIT>")<EOL>def bsp_left(node: tcod.bsp.BSP) -> Optional[tcod.bsp.BSP]: | return None if not node.children else node.children[<NUM_LIT:0>]<EOL> | .. deprecated:: 2.0
Use :any:`BSP.children` instead. | f3112:m7 |
@deprecate("<STR_LIT>")<EOL>def bsp_right(node: tcod.bsp.BSP) -> Optional[tcod.bsp.BSP]: | return None if not node.children else node.children[<NUM_LIT:1>]<EOL> | .. deprecated:: 2.0
Use :any:`BSP.children` instead. | f3112:m8 |
@deprecate("<STR_LIT>")<EOL>def bsp_father(node: tcod.bsp.BSP) -> Optional[tcod.bsp.BSP]: | return node.parent<EOL> | .. deprecated:: 2.0
Use :any:`BSP.parent` instead. | f3112:m9 |
@deprecate("<STR_LIT>")<EOL>def bsp_is_leaf(node: tcod.bsp.BSP) -> bool: | return not node.children<EOL> | .. deprecated:: 2.0
Use :any:`BSP.children` instead. | f3112:m10 |
@deprecate("<STR_LIT>")<EOL>def bsp_contains(node: tcod.bsp.BSP, cx: int, cy: int) -> bool: | return node.contains(cx, cy)<EOL> | .. deprecated:: 2.0
Use :any:`BSP.contains` instead. | f3112:m11 |
@deprecate("<STR_LIT>")<EOL>def bsp_find_node(<EOL>node: tcod.bsp.BSP, cx: int, cy: int<EOL>) -> Optional[tcod.bsp.BSP]: | return node.find_node(cx, cy)<EOL> | .. deprecated:: 2.0
Use :any:`BSP.find_node` instead. | f3112:m12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.