signature
stringlengths 8
3.44k
| body
stringlengths 0
1.41M
| docstring
stringlengths 1
122k
| id
stringlengths 5
17
|
|---|---|---|---|
def _bsp_traverse(<EOL>node_iter: Iterable[tcod.bsp.BSP],<EOL>callback: Callable[[tcod.bsp.BSP, Any], None],<EOL>userData: Any,<EOL>) -> None:
|
for node in node_iter:<EOL><INDENT>callback(node, userData)<EOL><DEDENT>
|
pack callback into a handle for use with the callback
_pycall_bsp_callback
|
f3112:m13
|
@deprecate("<STR_LIT>")<EOL>def bsp_traverse_pre_order(<EOL>node: tcod.bsp.BSP,<EOL>callback: Callable[[tcod.bsp.BSP, Any], None],<EOL>userData: Any = <NUM_LIT:0>,<EOL>) -> None:
|
_bsp_traverse(node.pre_order(), callback, userData)<EOL>
|
Traverse this nodes hierarchy with a callback.
.. deprecated:: 2.0
Use :any:`BSP.pre_order` instead.
|
f3112:m14
|
@deprecate("<STR_LIT>")<EOL>def bsp_traverse_in_order(<EOL>node: tcod.bsp.BSP,<EOL>callback: Callable[[tcod.bsp.BSP, Any], None],<EOL>userData: Any = <NUM_LIT:0>,<EOL>) -> None:
|
_bsp_traverse(node.in_order(), callback, userData)<EOL>
|
Traverse this nodes hierarchy with a callback.
.. deprecated:: 2.0
Use :any:`BSP.in_order` instead.
|
f3112:m15
|
@deprecate("<STR_LIT>")<EOL>def bsp_traverse_post_order(<EOL>node: tcod.bsp.BSP,<EOL>callback: Callable[[tcod.bsp.BSP, Any], None],<EOL>userData: Any = <NUM_LIT:0>,<EOL>) -> None:
|
_bsp_traverse(node.post_order(), callback, userData)<EOL>
|
Traverse this nodes hierarchy with a callback.
.. deprecated:: 2.0
Use :any:`BSP.post_order` instead.
|
f3112:m16
|
@deprecate("<STR_LIT>")<EOL>def bsp_traverse_level_order(<EOL>node: tcod.bsp.BSP,<EOL>callback: Callable[[tcod.bsp.BSP, Any], None],<EOL>userData: Any = <NUM_LIT:0>,<EOL>) -> None:
|
_bsp_traverse(node.level_order(), callback, userData)<EOL>
|
Traverse this nodes hierarchy with a callback.
.. deprecated:: 2.0
Use :any:`BSP.level_order` instead.
|
f3112:m17
|
@deprecate(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL>def bsp_traverse_inverted_level_order(<EOL>node: tcod.bsp.BSP,<EOL>callback: Callable[[tcod.bsp.BSP, Any], None],<EOL>userData: Any = <NUM_LIT:0>,<EOL>) -> None:
|
_bsp_traverse(node.inverted_level_order(), callback, userData)<EOL>
|
Traverse this nodes hierarchy with a callback.
.. deprecated:: 2.0
Use :any:`BSP.inverted_level_order` instead.
|
f3112:m18
|
@deprecate("<STR_LIT>")<EOL>def bsp_remove_sons(node: tcod.bsp.BSP) -> None:
|
node.children = ()<EOL>
|
Delete all children of a given node. Not recommended.
.. note::
This function will add unnecessary complexity to your code.
Don't use it.
.. deprecated:: 2.0
BSP deletion is automatic.
|
f3112:m19
|
@deprecate("<STR_LIT>")<EOL>def bsp_delete(node: tcod.bsp.BSP) -> None:
|
Exists for backward compatibility. Does nothing.
BSP's created by this library are automatically garbage collected once
there are no references to the tree.
This function exists for backwards compatibility.
.. deprecated:: 2.0
BSP deletion is automatic.
|
f3112:m20
|
|
@pending_deprecate()<EOL>def color_lerp(<EOL>c1: Tuple[int, int, int], c2: Tuple[int, int, int], a: float<EOL>) -> Color:
|
return Color._new_from_cdata(lib.TCOD_color_lerp(c1, c2, a))<EOL>
|
Return the linear interpolation between two colors.
``a`` is the interpolation value, with 0 returing ``c1``,
1 returning ``c2``, and 0.5 returing a color halfway between both.
Args:
c1 (Union[Tuple[int, int, int], Sequence[int]]):
The first color. At a=0.
c2 (Union[Tuple[int, int, int], Sequence[int]]):
The second color. At a=1.
a (float): The interpolation value,
Returns:
Color: The interpolated Color.
|
f3112:m21
|
@pending_deprecate()<EOL>def color_set_hsv(c: Color, h: float, s: float, v: float) -> None:
|
new_color = ffi.new("<STR_LIT>")<EOL>lib.TCOD_color_set_HSV(new_color, h, s, v)<EOL>c[:] = new_color.r, new_color.g, new_color.b<EOL>
|
Set a color using: hue, saturation, and value parameters.
Does not return a new Color. ``c`` is modified inplace.
Args:
c (Union[Color, List[Any]]): A Color instance, or a list of any kind.
h (float): Hue, from 0 to 360.
s (float): Saturation, from 0 to 1.
v (float): Value, from 0 to 1.
|
f3112:m22
|
@pending_deprecate()<EOL>def color_get_hsv(c: Tuple[int, int, int]) -> Tuple[float, float, float]:
|
hsv = ffi.new("<STR_LIT>")<EOL>lib.TCOD_color_get_HSV(c, hsv, hsv + <NUM_LIT:1>, hsv + <NUM_LIT:2>)<EOL>return hsv[<NUM_LIT:0>], hsv[<NUM_LIT:1>], hsv[<NUM_LIT:2>]<EOL>
|
Return the (hue, saturation, value) of a color.
Args:
c (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
Returns:
Tuple[float, float, float]:
A tuple with (hue, saturation, value) values, from 0 to 1.
|
f3112:m23
|
@pending_deprecate()<EOL>def color_scale_HSV(c: Color, scoef: float, vcoef: float) -> None:
|
color_p = ffi.new("<STR_LIT>")<EOL>color_p.r, color_p.g, color_p.b = c.r, c.g, c.b<EOL>lib.TCOD_color_scale_HSV(color_p, scoef, vcoef)<EOL>c[:] = color_p.r, color_p.g, color_p.b<EOL>
|
Scale a color's saturation and value.
Does not return a new Color. ``c`` is modified inplace.
Args:
c (Union[Color, List[int]]): A Color instance, or an [r, g, b] list.
scoef (float): Saturation multiplier, from 0 to 1.
Use 1 to keep current saturation.
vcoef (float): Value multiplier, from 0 to 1.
Use 1 to keep current value.
|
f3112:m24
|
@pending_deprecate()<EOL>def color_gen_map(<EOL>colors: Iterable[Tuple[int, int, int]], indexes: Iterable[int]<EOL>) -> List[Color]:
|
ccolors = ffi.new("<STR_LIT>", colors)<EOL>cindexes = ffi.new("<STR_LIT>", indexes)<EOL>cres = ffi.new("<STR_LIT>", max(indexes) + <NUM_LIT:1>)<EOL>lib.TCOD_color_gen_map(cres, len(ccolors), ccolors, cindexes)<EOL>return [Color._new_from_cdata(cdata) for cdata in cres]<EOL>
|
Return a smoothly defined scale of colors.
If ``indexes`` is [0, 3, 9] for example, the first color from ``colors``
will be returned at 0, the 2nd will be at 3, and the 3rd will be at 9.
All in-betweens will be filled with a gradient.
Args:
colors (Iterable[Union[Tuple[int, int, int], Sequence[int]]]):
Array of colors to be sampled.
indexes (Iterable[int]): A list of indexes.
Returns:
List[Color]: A list of Color instances.
Example:
>>> tcod.color_gen_map([(0, 0, 0), (255, 128, 0)], [0, 5])
[Color(0, 0, 0), Color(51, 25, 0), Color(102, 51, 0), \
Color(153, 76, 0), Color(204, 102, 0), Color(255, 128, 0)]
|
f3112:m25
|
def console_init_root(<EOL>w: int,<EOL>h: int,<EOL>title: Optional[str] = None,<EOL>fullscreen: bool = False,<EOL>renderer: Optional[int] = None,<EOL>order: str = "<STR_LIT:C>",<EOL>) -> tcod.console.Console:
|
if title is None:<EOL><INDENT>title = os.path.basename(sys.argv[<NUM_LIT:0>])<EOL><DEDENT>if renderer is None:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL>renderer = tcod.constants.RENDERER_SDL<EOL><DEDENT>elif renderer in (<EOL>tcod.constants.RENDERER_SDL,<EOL>tcod.constants.RENDERER_OPENGL,<EOL>tcod.constants.RENDERER_GLSL,<EOL>):<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL><DEDENT>lib.TCOD_console_init_root(w, h, _bytes(title), fullscreen, renderer)<EOL>console = tcod.console.Console._get_root(order)<EOL>console.clear()<EOL>return console<EOL>
|
Set up the primary display and return the root console.
`w` and `h` are the columns and rows of the new window (in tiles.)
`title` is an optional string to display on the windows title bar.
`fullscreen` determines if the window will start in fullscreen. Fullscreen
mode is unreliable unless the renderer is set to `tcod.RENDERER_SDL2` or
`tcod.RENDERER_OPENGL2`.
`renderer` is the rendering back-end that libtcod will use.
If you don't know which to pick, then use `tcod.RENDERER_SDL2`.
Options are:
* `tcod.RENDERER_SDL`:
A deprecated software/SDL2 renderer.
* `tcod.RENDERER_OPENGL`:
A deprecated SDL2/OpenGL1 renderer.
* `tcod.RENDERER_GLSL`:
A deprecated SDL2/OpenGL2 renderer.
* `tcod.RENDERER_SDL2`:
The recommended SDL2 renderer. Rendering is decided by SDL2 and can be
changed by using an SDL2 hint.
* `tcod.RENDERER_OPENGL2`:
An SDL2/OPENGL2 renderer. Usually faster than regular SDL2.
Requires OpenGL 2.0 Core.
`order` will affect how the array attributes of the returned root console
are indexed. `order='C'` is the default, but `order='F'` is recommended.
.. versionchanged:: 4.3
Added `order` parameter.
`title` parameter is now optional.
.. versionchanged:: 8.0
The default `renderer` is now automatic instead of always being
`RENDERER_SDL`.
|
f3112:m26
|
def console_set_custom_font(<EOL>fontFile: AnyStr,<EOL>flags: int = FONT_LAYOUT_ASCII_INCOL,<EOL>nb_char_horiz: int = <NUM_LIT:0>,<EOL>nb_char_vertic: int = <NUM_LIT:0>,<EOL>) -> None:
|
if not os.path.exists(fontFile):<EOL><INDENT>raise RuntimeError(<EOL>"<STR_LIT>" % (os.path.realpath(fontFile),)<EOL>)<EOL><DEDENT>lib.TCOD_console_set_custom_font(<EOL>_bytes(fontFile), flags, nb_char_horiz, nb_char_vertic<EOL>)<EOL>
|
Load the custom font file at `fontFile`.
Call this before function before calling :any:`tcod.console_init_root`.
Flags can be a mix of the following:
* tcod.FONT_LAYOUT_ASCII_INCOL:
Decode tileset raw in column-major order.
* tcod.FONT_LAYOUT_ASCII_INROW:
Decode tileset raw in row-major order.
* tcod.FONT_TYPE_GREYSCALE:
Force tileset to be read as greyscale.
* tcod.FONT_TYPE_GRAYSCALE
* tcod.FONT_LAYOUT_TCOD:
Unique layout used by libtcod.
* tcod.FONT_LAYOUT_CP437:
Decode a row-major Code Page 437 tileset into Unicode.
`nb_char_horiz` and `nb_char_vertic` are the columns and rows of the font
file respectfully.
|
f3112:m27
|
@deprecate("<STR_LIT>")<EOL>def console_get_width(con: tcod.console.Console) -> int:
|
return int(lib.TCOD_console_get_width(_console(con)))<EOL>
|
Return the width of a console.
Args:
con (Console): Any Console instance.
Returns:
int: The width of a Console.
.. deprecated:: 2.0
Use `Console.width` instead.
|
f3112:m28
|
@deprecate("<STR_LIT>")<EOL>def console_get_height(con: tcod.console.Console) -> int:
|
return int(lib.TCOD_console_get_height(_console(con)))<EOL>
|
Return the height of a console.
Args:
con (Console): Any Console instance.
Returns:
int: The height of a Console.
.. deprecated:: 2.0
Use `Console.height` instead.
|
f3112:m29
|
@pending_deprecate()<EOL>def console_map_ascii_code_to_font(<EOL>asciiCode: int, fontCharX: int, fontCharY: int<EOL>) -> None:
|
lib.TCOD_console_map_ascii_code_to_font(<EOL>_int(asciiCode), fontCharX, fontCharY<EOL>)<EOL>
|
Set a character code to new coordinates on the tile-set.
`asciiCode` must be within the bounds created during the initialization of
the loaded tile-set. For example, you can't use 255 here unless you have a
256 tile tile-set loaded. This applies to all functions in this group.
Args:
asciiCode (int): The character code to change.
fontCharX (int): The X tile coordinate on the loaded tileset.
0 is the leftmost tile.
fontCharY (int): The Y tile coordinate on the loaded tileset.
0 is the topmost tile.
|
f3112:m30
|
@pending_deprecate()<EOL>def console_map_ascii_codes_to_font(<EOL>firstAsciiCode: int, nbCodes: int, fontCharX: int, fontCharY: int<EOL>) -> None:
|
lib.TCOD_console_map_ascii_codes_to_font(<EOL>_int(firstAsciiCode), nbCodes, fontCharX, fontCharY<EOL>)<EOL>
|
Remap a contiguous set of codes to a contiguous set of tiles.
Both the tile-set and character codes must be contiguous to use this
function. If this is not the case you may want to use
:any:`console_map_ascii_code_to_font`.
Args:
firstAsciiCode (int): The starting character code.
nbCodes (int): The length of the contiguous set.
fontCharX (int): The starting X tile coordinate on the loaded tileset.
0 is the leftmost tile.
fontCharY (int): The starting Y tile coordinate on the loaded tileset.
0 is the topmost tile.
|
f3112:m31
|
@pending_deprecate()<EOL>def console_map_string_to_font(s: str, fontCharX: int, fontCharY: int) -> None:
|
lib.TCOD_console_map_string_to_font_utf(_unicode(s), fontCharX, fontCharY)<EOL>
|
Remap a string of codes to a contiguous set of tiles.
Args:
s (AnyStr): A string of character codes to map to new values.
The null character `'\\x00'` will prematurely end this
function.
fontCharX (int): The starting X tile coordinate on the loaded tileset.
0 is the leftmost tile.
fontCharY (int): The starting Y tile coordinate on the loaded tileset.
0 is the topmost tile.
|
f3112:m32
|
def console_is_fullscreen() -> bool:
|
return bool(lib.TCOD_console_is_fullscreen())<EOL>
|
Returns True if the display is fullscreen.
Returns:
bool: True if the display is fullscreen, otherwise False.
|
f3112:m33
|
def console_set_fullscreen(fullscreen: bool) -> None:
|
lib.TCOD_console_set_fullscreen(fullscreen)<EOL>
|
Change the display to be fullscreen or windowed.
Args:
fullscreen (bool): Use True to change to fullscreen.
Use False to change to windowed.
|
f3112:m34
|
@deprecate('<STR_LIT>')<EOL>def console_is_window_closed() -> bool:
|
return bool(lib.TCOD_console_is_window_closed())<EOL>
|
Returns True if the window has received and exit event.
.. deprecated:: 9.3
Use the :any:`tcod.event` module to check for "QUIT" type events.
|
f3112:m35
|
@pending_deprecate()<EOL>def console_has_mouse_focus() -> bool:
|
return bool(lib.TCOD_console_has_mouse_focus())<EOL>
|
Return True if the window has mouse focus.
|
f3112:m36
|
@pending_deprecate()<EOL>def console_is_active() -> bool:
|
return bool(lib.TCOD_console_is_active())<EOL>
|
Return True if the window has keyboard focus.
|
f3112:m37
|
def console_set_window_title(title: str) -> None:
|
lib.TCOD_console_set_window_title(_bytes(title))<EOL>
|
Change the current title bar string.
Args:
title (AnyStr): A string to change the title bar to.
|
f3112:m38
|
def console_flush() -> None:
|
lib.TCOD_console_flush()<EOL>
|
Update the display to represent the root consoles current state.
|
f3112:m42
|
@deprecate("<STR_LIT>")<EOL>def console_set_default_background(<EOL>con: tcod.console.Console, col: Tuple[int, int, int]<EOL>) -> None:
|
lib.TCOD_console_set_default_background(_console(con), col)<EOL>
|
Change the default background color for a console.
Args:
con (Console): Any Console instance.
col (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
.. deprecated:: 8.5
Use :any:`Console.default_bg` instead.
|
f3112:m43
|
@deprecate("<STR_LIT>")<EOL>def console_set_default_foreground(<EOL>con: tcod.console.Console, col: Tuple[int, int, int]<EOL>) -> None:
|
lib.TCOD_console_set_default_foreground(_console(con), col)<EOL>
|
Change the default foreground color for a console.
Args:
con (Console): Any Console instance.
col (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
.. deprecated:: 8.5
Use :any:`Console.default_fg` instead.
|
f3112:m44
|
@deprecate("<STR_LIT>")<EOL>def console_clear(con: tcod.console.Console) -> None:
|
lib.TCOD_console_clear(_console(con))<EOL>
|
Reset a console to its default colors and the space character.
Args:
con (Console): Any Console instance.
.. seealso::
:any:`console_set_default_background`
:any:`console_set_default_foreground`
.. deprecated:: 8.5
Call the :any:`Console.clear` method instead.
|
f3112:m45
|
@pending_deprecate()<EOL>def console_put_char(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>c: Union[int, str],<EOL>flag: int = BKGND_DEFAULT,<EOL>) -> None:
|
lib.TCOD_console_put_char(_console(con), x, y, _int(c), flag)<EOL>
|
Draw the character c at x,y using the default colors and a blend mode.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
c (Union[int, AnyStr]): Character to draw, can be an integer or string.
flag (int): Blending mode to use, defaults to BKGND_DEFAULT.
|
f3112:m46
|
@pending_deprecate()<EOL>def console_put_char_ex(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>c: Union[int, str],<EOL>fore: Tuple[int, int, int],<EOL>back: Tuple[int, int, int],<EOL>) -> None:
|
lib.TCOD_console_put_char_ex(_console(con), x, y, _int(c), fore, back)<EOL>
|
Draw the character c at x,y using the colors fore and back.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
c (Union[int, AnyStr]): Character to draw, can be an integer or string.
fore (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
back (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
|
f3112:m47
|
@pending_deprecate()<EOL>def console_set_char_background(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>col: Tuple[int, int, int],<EOL>flag: int = BKGND_SET,<EOL>) -> None:
|
lib.TCOD_console_set_char_background(_console(con), x, y, col, flag)<EOL>
|
Change the background color of x,y to col using a blend mode.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
col (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
flag (int): Blending mode to use, defaults to BKGND_SET.
|
f3112:m48
|
@deprecate("<STR_LIT>")<EOL>def console_set_char_foreground(<EOL>con: tcod.console.Console, x: int, y: int, col: Tuple[int, int, int]<EOL>) -> None:
|
lib.TCOD_console_set_char_foreground(_console(con), x, y, col)<EOL>
|
Change the foreground color of x,y to col.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
col (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
.. deprecated:: 8.4
Array access performs significantly faster than using this function.
See :any:`Console.fg`.
|
f3112:m49
|
@deprecate("<STR_LIT>")<EOL>def console_set_char(<EOL>con: tcod.console.Console, x: int, y: int, c: Union[int, str]<EOL>) -> None:
|
lib.TCOD_console_set_char(_console(con), x, y, _int(c))<EOL>
|
Change the character at x,y to c, keeping the current colors.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
c (Union[int, AnyStr]): Character to draw, can be an integer or string.
.. deprecated:: 8.4
Array access performs significantly faster than using this function.
See :any:`Console.ch`.
|
f3112:m50
|
@deprecate("<STR_LIT>")<EOL>def console_set_background_flag(con: tcod.console.Console, flag: int) -> None:
|
lib.TCOD_console_set_background_flag(_console(con), flag)<EOL>
|
Change the default blend mode for this console.
Args:
con (Console): Any Console instance.
flag (int): Blend mode to use by default.
.. deprecated:: 8.5
Set :any:`Console.default_bg_blend` instead.
|
f3112:m51
|
@deprecate("<STR_LIT>")<EOL>def console_get_background_flag(con: tcod.console.Console) -> int:
|
return int(lib.TCOD_console_get_background_flag(_console(con)))<EOL>
|
Return this consoles current blend mode.
Args:
con (Console): Any Console instance.
.. deprecated:: 8.5
Check :any:`Console.default_bg_blend` instead.
|
f3112:m52
|
@deprecate("<STR_LIT>")<EOL>def console_set_alignment(con: tcod.console.Console, alignment: int) -> None:
|
lib.TCOD_console_set_alignment(_console(con), alignment)<EOL>
|
Change this consoles current alignment mode.
* tcod.LEFT
* tcod.CENTER
* tcod.RIGHT
Args:
con (Console): Any Console instance.
alignment (int):
.. deprecated:: 8.5
Set :any:`Console.default_alignment` instead.
|
f3112:m53
|
@deprecate("<STR_LIT>")<EOL>def console_get_alignment(con: tcod.console.Console) -> int:
|
return int(lib.TCOD_console_get_alignment(_console(con)))<EOL>
|
Return this consoles current alignment mode.
Args:
con (Console): Any Console instance.
.. deprecated:: 8.5
Check :any:`Console.default_alignment` instead.
|
f3112:m54
|
@deprecate("<STR_LIT>")<EOL>def console_print(con: tcod.console.Console, x: int, y: int, fmt: str) -> None:
|
lib.TCOD_console_printf(_console(con), x, y, _fmt(fmt))<EOL>
|
Print a color formatted string on a console.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
fmt (AnyStr): A unicode or bytes string optionaly using color codes.
.. deprecated:: 8.5
Use :any:`Console.print_` instead.
|
f3112:m55
|
@deprecate("<STR_LIT>")<EOL>def console_print_ex(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>flag: int,<EOL>alignment: int,<EOL>fmt: str,<EOL>) -> None:
|
lib.TCOD_console_printf_ex(_console(con), x, y, flag, alignment, _fmt(fmt))<EOL>
|
Print a string on a console using a blend mode and alignment mode.
Args:
con (Console): Any Console instance.
x (int): Character x position from the left.
y (int): Character y position from the top.
.. deprecated:: 8.5
Use :any:`Console.print_` instead.
|
f3112:m56
|
@deprecate("<STR_LIT>")<EOL>def console_print_rect(<EOL>con: tcod.console.Console, x: int, y: int, w: int, h: int, fmt: str<EOL>) -> int:
|
return int(<EOL>lib.TCOD_console_printf_rect(_console(con), x, y, w, h, _fmt(fmt))<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.
Returns:
int: The number of lines of text once word-wrapped.
.. deprecated:: 8.5
Use :any:`Console.print_rect` instead.
|
f3112:m57
|
@deprecate("<STR_LIT>")<EOL>def console_print_rect_ex(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>w: int,<EOL>h: int,<EOL>flag: int,<EOL>alignment: int,<EOL>fmt: str,<EOL>) -> int:
|
return int(<EOL>lib.TCOD_console_printf_rect_ex(<EOL>_console(con), x, y, w, h, flag, alignment, _fmt(fmt)<EOL>)<EOL>)<EOL>
|
Print a string constrained to a rectangle with blend and alignment.
Returns:
int: The number of lines of text once word-wrapped.
.. deprecated:: 8.5
Use :any:`Console.print_rect` instead.
|
f3112:m58
|
@deprecate("<STR_LIT>")<EOL>def console_get_height_rect(<EOL>con: tcod.console.Console, x: int, y: int, w: int, h: int, fmt: str<EOL>) -> int:
|
return int(<EOL>lib.TCOD_console_get_height_rect_fmt(<EOL>_console(con), x, y, w, h, _fmt(fmt)<EOL>)<EOL>)<EOL>
|
Return the height of this text once word-wrapped into this rectangle.
Returns:
int: The number of lines of text once word-wrapped.
.. deprecated:: 8.5
Use :any:`Console.get_height_rect` instead.
|
f3112:m59
|
@deprecate("<STR_LIT>")<EOL>def console_rect(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>w: int,<EOL>h: int,<EOL>clr: bool,<EOL>flag: int = BKGND_DEFAULT,<EOL>) -> None:
|
lib.TCOD_console_rect(_console(con), x, y, w, h, clr, flag)<EOL>
|
Draw a the background color on a rect optionally clearing the text.
If clr is True the affected tiles are changed to space character.
.. deprecated:: 8.5
Use :any:`Console.rect` instead.
|
f3112:m60
|
@deprecate("<STR_LIT>")<EOL>def console_hline(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>l: int,<EOL>flag: int = BKGND_DEFAULT,<EOL>) -> None:
|
lib.TCOD_console_hline(_console(con), x, y, l, flag)<EOL>
|
Draw a horizontal line on the console.
This always uses the character 196, the horizontal line character.
.. deprecated:: 8.5
Use :any:`Console.hline` instead.
|
f3112:m61
|
@deprecate("<STR_LIT>")<EOL>def console_vline(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>l: int,<EOL>flag: int = BKGND_DEFAULT,<EOL>) -> None:
|
lib.TCOD_console_vline(_console(con), x, y, l, flag)<EOL>
|
Draw a vertical line on the console.
This always uses the character 179, the vertical line character.
.. deprecated:: 8.5
Use :any:`Console.vline` instead.
|
f3112:m62
|
@deprecate("<STR_LIT>")<EOL>def console_print_frame(<EOL>con: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>w: int,<EOL>h: int,<EOL>clear: bool = True,<EOL>flag: int = BKGND_DEFAULT,<EOL>fmt: str = "<STR_LIT>",<EOL>) -> None:
|
fmt = _fmt(fmt) if fmt else ffi.NULL<EOL>lib.TCOD_console_printf_frame(_console(con), x, y, w, h, clear, flag, fmt)<EOL>
|
Draw a framed rectangle with optinal text.
This uses the default background color and blend mode to fill the
rectangle and the default foreground to draw the outline.
`fmt` will be printed on the inside of the rectangle, word-wrapped.
If `fmt` is empty then no title will be drawn.
.. versionchanged:: 8.2
Now supports Unicode strings.
.. deprecated:: 8.5
Use :any:`Console.print_frame` instead.
|
f3112:m63
|
@pending_deprecate()<EOL>def console_set_color_control(<EOL>con: int, fore: Tuple[int, int, int], back: Tuple[int, int, int]<EOL>) -> None:
|
lib.TCOD_console_set_color_control(con, fore, back)<EOL>
|
Configure :any:`color controls`.
Args:
con (int): :any:`Color control` constant to modify.
fore (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
back (Union[Tuple[int, int, int], Sequence[int]]):
An (r, g, b) sequence or Color instance.
|
f3112:m64
|
@deprecate("<STR_LIT>")<EOL>def console_get_default_background(con: tcod.console.Console) -> Color:
|
return Color._new_from_cdata(<EOL>lib.TCOD_console_get_default_background(_console(con))<EOL>)<EOL>
|
Return this consoles default background color.
.. deprecated:: 8.5
Use :any:`Console.default_bg` instead.
|
f3112:m65
|
@deprecate("<STR_LIT>")<EOL>def console_get_default_foreground(con: tcod.console.Console) -> Color:
|
return Color._new_from_cdata(<EOL>lib.TCOD_console_get_default_foreground(_console(con))<EOL>)<EOL>
|
Return this consoles default foreground color.
.. deprecated:: 8.5
Use :any:`Console.default_fg` instead.
|
f3112:m66
|
@deprecate("<STR_LIT>")<EOL>def console_get_char_background(<EOL>con: tcod.console.Console, x: int, y: int<EOL>) -> Color:
|
return Color._new_from_cdata(<EOL>lib.TCOD_console_get_char_background(_console(con), x, y)<EOL>)<EOL>
|
Return the background color at the x,y of this console.
.. deprecated:: 8.4
Array access performs significantly faster than using this function.
See :any:`Console.bg`.
|
f3112:m67
|
@deprecate("<STR_LIT>")<EOL>def console_get_char_foreground(<EOL>con: tcod.console.Console, x: int, y: int<EOL>) -> Color:
|
return Color._new_from_cdata(<EOL>lib.TCOD_console_get_char_foreground(_console(con), x, y)<EOL>)<EOL>
|
Return the foreground color at the x,y of this console.
.. deprecated:: 8.4
Array access performs significantly faster than using this function.
See :any:`Console.fg`.
|
f3112:m68
|
@deprecate("<STR_LIT>")<EOL>def console_get_char(con: tcod.console.Console, x: int, y: int) -> int:
|
return lib.TCOD_console_get_char(_console(con), x, y)<EOL>
|
Return the character at the x,y of this console.
.. deprecated:: 8.4
Array access performs significantly faster than using this function.
See :any:`Console.ch`.
|
f3112:m69
|
@deprecate("<STR_LIT>")<EOL>def console_wait_for_keypress(flush: bool) -> Key:
|
key = Key()<EOL>lib.TCOD_console_wait_for_keypress_wrapper(key.key_p, flush)<EOL>return key<EOL>
|
Block until the user presses a key, then returns a new Key.
Args:
flush bool: If True then the event queue is cleared before waiting
for the next event.
Returns:
Key: A new Key instance.
.. deprecated:: 9.3
Use the :any:`tcod.event.wait` function to wait for events.
|
f3112:m73
|
@deprecate("<STR_LIT>")<EOL>def console_check_for_keypress(flags: int = KEY_RELEASED) -> Key:
|
key = Key()<EOL>lib.TCOD_console_check_for_keypress_wrapper(key.key_p, flags)<EOL>return key<EOL>
|
.. deprecated:: 9.3
Use the :any:`tcod.event.get` function to check for events.
|
f3112:m74
|
@deprecate("<STR_LIT>")<EOL>def console_new(w: int, h: int) -> tcod.console.Console:
|
return tcod.console.Console(w, h)<EOL>
|
Return an offscreen console of size: w,h.
.. deprecated:: 8.5
Create new consoles using :any:`tcod.console.Console` instead of this
function.
|
f3112:m76
|
def console_from_file(filename: str) -> tcod.console.Console:
|
return tcod.console.Console._from_cdata(<EOL>lib.TCOD_console_from_file(filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Return a new console object from a filename.
The file format is automactially determined. This can load REXPaint `.xp`,
ASCII Paint `.apf`, or Non-delimited ASCII `.asc` files.
Args:
filename (Text): The path to the file, as a string.
Returns: A new :any`Console` instance.
|
f3112:m77
|
@deprecate("<STR_LIT>")<EOL>def console_blit(<EOL>src: tcod.console.Console,<EOL>x: int,<EOL>y: int,<EOL>w: int,<EOL>h: int,<EOL>dst: tcod.console.Console,<EOL>xdst: int,<EOL>ydst: int,<EOL>ffade: float = <NUM_LIT:1.0>,<EOL>bfade: float = <NUM_LIT:1.0>,<EOL>) -> None:
|
lib.TCOD_console_blit(<EOL>_console(src), x, y, w, h, _console(dst), xdst, ydst, ffade, bfade<EOL>)<EOL>
|
Blit the console src from x,y,w,h to console dst at xdst,ydst.
.. deprecated:: 8.5
Call the :any:`Console.blit` method instead.
|
f3112:m78
|
@deprecate(<EOL>"<STR_LIT>"<EOL>)<EOL>def console_set_key_color(<EOL>con: tcod.console.Console, col: Tuple[int, int, int]<EOL>) -> None:
|
lib.TCOD_console_set_key_color(_console(con), col)<EOL>if hasattr(con, "<STR_LIT>"):<EOL><INDENT>con.set_key_color(col)<EOL><DEDENT>
|
Set a consoles blit transparent color.
.. deprecated:: 8.5
Pass the key color to :any:`tcod.console.Console.blit` instead of
calling this function.
|
f3112:m79
|
def console_delete(con: tcod.console.Console) -> None:
|
con = _console(con)<EOL>if con == ffi.NULL:<EOL><INDENT>lib.TCOD_console_delete(con)<EOL>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL><DEDENT>
|
Closes the window if `con` is the root console.
libtcod objects are automatically garbage collected once they go out of
scope.
This function exists for backwards compatibility.
.. deprecated:: 9.3
This function is not needed for normal :any:`tcod.console.Console`'s.
The root console should be used in a with statement instead to ensure
that it closes.
|
f3112:m80
|
@deprecate("<STR_LIT>")<EOL>def console_fill_foreground(<EOL>con: tcod.console.Console,<EOL>r: Sequence[int],<EOL>g: Sequence[int],<EOL>b: Sequence[int],<EOL>) -> None:
|
if len(r) != len(g) or len(r) != len(b):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if (<EOL>isinstance(r, np.ndarray)<EOL>and isinstance(g, np.ndarray)<EOL>and isinstance(b, np.ndarray)<EOL>):<EOL><INDENT>r_ = np.ascontiguousarray(r, dtype=np.intc)<EOL>g_ = np.ascontiguousarray(g, dtype=np.intc)<EOL>b_ = np.ascontiguousarray(b, dtype=np.intc)<EOL>cr = ffi.cast("<STR_LIT>", r_.ctypes.data)<EOL>cg = ffi.cast("<STR_LIT>", g_.ctypes.data)<EOL>cb = ffi.cast("<STR_LIT>", b_.ctypes.data)<EOL><DEDENT>else:<EOL><INDENT>cr = ffi.new("<STR_LIT>", r)<EOL>cg = ffi.new("<STR_LIT>", g)<EOL>cb = ffi.new("<STR_LIT>", b)<EOL><DEDENT>lib.TCOD_console_fill_foreground(_console(con), cr, cg, cb)<EOL>
|
Fill the foregound of a console with r,g,b.
Args:
con (Console): Any Console instance.
r (Sequence[int]): An array of integers with a length of width*height.
g (Sequence[int]): An array of integers with a length of width*height.
b (Sequence[int]): An array of integers with a length of width*height.
.. deprecated:: 8.4
You should assign to :any:`tcod.console.Console.fg` instead.
|
f3112:m81
|
@deprecate("<STR_LIT>")<EOL>def console_fill_background(<EOL>con: tcod.console.Console,<EOL>r: Sequence[int],<EOL>g: Sequence[int],<EOL>b: Sequence[int],<EOL>) -> None:
|
if len(r) != len(g) or len(r) != len(b):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if (<EOL>isinstance(r, np.ndarray)<EOL>and isinstance(g, np.ndarray)<EOL>and isinstance(b, np.ndarray)<EOL>):<EOL><INDENT>r_ = np.ascontiguousarray(r, dtype=np.intc)<EOL>g_ = np.ascontiguousarray(g, dtype=np.intc)<EOL>b_ = np.ascontiguousarray(b, dtype=np.intc)<EOL>cr = ffi.cast("<STR_LIT>", r_.ctypes.data)<EOL>cg = ffi.cast("<STR_LIT>", g_.ctypes.data)<EOL>cb = ffi.cast("<STR_LIT>", b_.ctypes.data)<EOL><DEDENT>else:<EOL><INDENT>cr = ffi.new("<STR_LIT>", r)<EOL>cg = ffi.new("<STR_LIT>", g)<EOL>cb = ffi.new("<STR_LIT>", b)<EOL><DEDENT>lib.TCOD_console_fill_background(_console(con), cr, cg, cb)<EOL>
|
Fill the backgound of a console with r,g,b.
Args:
con (Console): Any Console instance.
r (Sequence[int]): An array of integers with a length of width*height.
g (Sequence[int]): An array of integers with a length of width*height.
b (Sequence[int]): An array of integers with a length of width*height.
.. deprecated:: 8.4
You should assign to :any:`tcod.console.Console.bg` instead.
|
f3112:m82
|
@deprecate("<STR_LIT>")<EOL>def console_fill_char(con: tcod.console.Console, arr: Sequence[int]) -> None:
|
if isinstance(arr, np.ndarray):<EOL><INDENT>np_array = np.ascontiguousarray(arr, dtype=np.intc)<EOL>carr = ffi.cast("<STR_LIT>", np_array.ctypes.data)<EOL><DEDENT>else:<EOL><INDENT>carr = ffi.new("<STR_LIT>", arr)<EOL><DEDENT>lib.TCOD_console_fill_char(_console(con), carr)<EOL>
|
Fill the character tiles of a console with an array.
`arr` is an array of integers with a length of the consoles width and
height.
.. deprecated:: 8.4
You should assign to :any:`tcod.console.Console.ch` instead.
|
f3112:m83
|
@pending_deprecate()<EOL>def console_load_asc(con: tcod.console.Console, filename: str) -> bool:
|
return bool(<EOL>lib.TCOD_console_load_asc(_console(con), filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Update a console from a non-delimited ASCII `.asc` file.
|
f3112:m84
|
@pending_deprecate()<EOL>def console_save_asc(con: tcod.console.Console, filename: str) -> bool:
|
return bool(<EOL>lib.TCOD_console_save_asc(_console(con), filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Save a console to a non-delimited ASCII `.asc` file.
|
f3112:m85
|
@pending_deprecate()<EOL>def console_load_apf(con: tcod.console.Console, filename: str) -> bool:
|
return bool(<EOL>lib.TCOD_console_load_apf(_console(con), filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Update a console from an ASCII Paint `.apf` file.
|
f3112:m86
|
@pending_deprecate()<EOL>def console_save_apf(con: tcod.console.Console, filename: str) -> bool:
|
return bool(<EOL>lib.TCOD_console_save_apf(_console(con), filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Save a console to an ASCII Paint `.apf` file.
|
f3112:m87
|
def console_load_xp(con: tcod.console.Console, filename: str) -> bool:
|
return bool(<EOL>lib.TCOD_console_load_xp(_console(con), filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Update a console from a REXPaint `.xp` file.
|
f3112:m88
|
def console_save_xp(<EOL>con: tcod.console.Console, filename: str, compress_level: int = <NUM_LIT:9><EOL>) -> bool:
|
return bool(<EOL>lib.TCOD_console_save_xp(<EOL>_console(con), filename.encode("<STR_LIT:utf-8>"), compress_level<EOL>)<EOL>)<EOL>
|
Save a console to a REXPaint `.xp` file.
|
f3112:m89
|
def console_from_xp(filename: str) -> tcod.console.Console:
|
return tcod.console.Console._from_cdata(<EOL>lib.TCOD_console_from_xp(filename.encode("<STR_LIT:utf-8>"))<EOL>)<EOL>
|
Return a single console from a REXPaint `.xp` file.
|
f3112:m90
|
def console_list_load_xp(<EOL>filename: str<EOL>) -> Optional[List[tcod.console.Console]]:
|
tcod_list = lib.TCOD_console_list_from_xp(filename.encode("<STR_LIT:utf-8>"))<EOL>if tcod_list == ffi.NULL:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>python_list = []<EOL>lib.TCOD_list_reverse(tcod_list)<EOL>while not lib.TCOD_list_is_empty(tcod_list):<EOL><INDENT>python_list.append(<EOL>tcod.console.Console._from_cdata(lib.TCOD_list_pop(tcod_list))<EOL>)<EOL><DEDENT>return python_list<EOL><DEDENT>finally:<EOL><INDENT>lib.TCOD_list_delete(tcod_list)<EOL><DEDENT>
|
Return a list of consoles from a REXPaint `.xp` file.
|
f3112:m91
|
def console_list_save_xp(<EOL>console_list: Sequence[tcod.console.Console],<EOL>filename: str,<EOL>compress_level: int = <NUM_LIT:9>,<EOL>) -> bool:
|
tcod_list = lib.TCOD_list_new()<EOL>try:<EOL><INDENT>for console in console_list:<EOL><INDENT>lib.TCOD_list_push(tcod_list, _console(console))<EOL><DEDENT>return bool(<EOL>lib.TCOD_console_list_save_xp(<EOL>tcod_list, filename.encode("<STR_LIT:utf-8>"), compress_level<EOL>)<EOL>)<EOL><DEDENT>finally:<EOL><INDENT>lib.TCOD_list_delete(tcod_list)<EOL><DEDENT>
|
Save a list of consoles to a REXPaint `.xp` file.
|
f3112:m92
|
@pending_deprecate()<EOL>def path_new_using_map(<EOL>m: tcod.map.Map, dcost: float = <NUM_LIT><EOL>) -> tcod.path.AStar:
|
return tcod.path.AStar(m, dcost)<EOL>
|
Return a new AStar using the given Map.
Args:
m (Map): A Map instance.
dcost (float): The path-finding cost of diagonal movement.
Can be set to 0 to disable diagonal movement.
Returns:
AStar: A new AStar instance.
|
f3112:m93
|
@pending_deprecate()<EOL>def path_new_using_function(<EOL>w: int,<EOL>h: int,<EOL>func: Callable[[int, int, int, int, Any], float],<EOL>userData: Any = <NUM_LIT:0>,<EOL>dcost: float = <NUM_LIT>,<EOL>) -> tcod.path.AStar:
|
return tcod.path.AStar(<EOL>tcod.path._EdgeCostFunc((func, userData), (w, h)), dcost<EOL>)<EOL>
|
Return a new AStar using the given callable function.
Args:
w (int): Clipping width.
h (int): Clipping height.
func (Callable[[int, int, int, int, Any], float]):
userData (Any):
dcost (float): A multiplier for the cost of diagonal movement.
Can be set to 0 to disable diagonal movement.
Returns:
AStar: A new AStar instance.
|
f3112:m94
|
@pending_deprecate()<EOL>def path_compute(<EOL>p: tcod.path.AStar, ox: int, oy: int, dx: int, dy: int<EOL>) -> bool:
|
return bool(lib.TCOD_path_compute(p._path_c, ox, oy, dx, dy))<EOL>
|
Find a path from (ox, oy) to (dx, dy). Return True if path is found.
Args:
p (AStar): An AStar instance.
ox (int): Starting x position.
oy (int): Starting y position.
dx (int): Destination x position.
dy (int): Destination y position.
Returns:
bool: True if a valid path was found. Otherwise False.
|
f3112:m95
|
@pending_deprecate()<EOL>def path_get_origin(p: tcod.path.AStar) -> Tuple[int, int]:
|
x = ffi.new("<STR_LIT>")<EOL>y = ffi.new("<STR_LIT>")<EOL>lib.TCOD_path_get_origin(p._path_c, x, y)<EOL>return x[<NUM_LIT:0>], y[<NUM_LIT:0>]<EOL>
|
Get the current origin position.
This point moves when :any:`path_walk` returns the next x,y step.
Args:
p (AStar): An AStar instance.
Returns:
Tuple[int, int]: An (x, y) point.
|
f3112:m96
|
@pending_deprecate()<EOL>def path_get_destination(p: tcod.path.AStar) -> Tuple[int, int]:
|
x = ffi.new("<STR_LIT>")<EOL>y = ffi.new("<STR_LIT>")<EOL>lib.TCOD_path_get_destination(p._path_c, x, y)<EOL>return x[<NUM_LIT:0>], y[<NUM_LIT:0>]<EOL>
|
Get the current destination position.
Args:
p (AStar): An AStar instance.
Returns:
Tuple[int, int]: An (x, y) point.
|
f3112:m97
|
@pending_deprecate()<EOL>def path_size(p: tcod.path.AStar) -> int:
|
return int(lib.TCOD_path_size(p._path_c))<EOL>
|
Return the current length of the computed path.
Args:
p (AStar): An AStar instance.
Returns:
int: Length of the path.
|
f3112:m98
|
@pending_deprecate()<EOL>def path_reverse(p: tcod.path.AStar) -> None:
|
lib.TCOD_path_reverse(p._path_c)<EOL>
|
Reverse the direction of a path.
This effectively swaps the origin and destination points.
Args:
p (AStar): An AStar instance.
|
f3112:m99
|
@pending_deprecate()<EOL>def path_get(p: tcod.path.AStar, idx: int) -> Tuple[int, int]:
|
x = ffi.new("<STR_LIT>")<EOL>y = ffi.new("<STR_LIT>")<EOL>lib.TCOD_path_get(p._path_c, idx, x, y)<EOL>return x[<NUM_LIT:0>], y[<NUM_LIT:0>]<EOL>
|
Get a point on a path.
Args:
p (AStar): An AStar instance.
idx (int): Should be in range: 0 <= inx < :any:`path_size`
|
f3112:m100
|
@pending_deprecate()<EOL>def path_is_empty(p: tcod.path.AStar) -> bool:
|
return bool(lib.TCOD_path_is_empty(p._path_c))<EOL>
|
Return True if a path is empty.
Args:
p (AStar): An AStar instance.
Returns:
bool: True if a path is empty. Otherwise False.
|
f3112:m101
|
@pending_deprecate()<EOL>def path_walk(<EOL>p: tcod.path.AStar, recompute: bool<EOL>) -> Union[Tuple[int, int], Tuple[None, None]]:
|
x = ffi.new("<STR_LIT>")<EOL>y = ffi.new("<STR_LIT>")<EOL>if lib.TCOD_path_walk(p._path_c, x, y, recompute):<EOL><INDENT>return x[<NUM_LIT:0>], y[<NUM_LIT:0>]<EOL><DEDENT>return None, None<EOL>
|
Return the next (x, y) point in a path, or (None, None) if it's empty.
When ``recompute`` is True and a previously valid path reaches a point
where it is now blocked, a new path will automatically be found.
Args:
p (AStar): An AStar instance.
recompute (bool): Recompute the path automatically.
Returns:
Union[Tuple[int, int], Tuple[None, None]]:
A single (x, y) point, or (None, None)
|
f3112:m102
|
@deprecate("<STR_LIT>")<EOL>def path_delete(p: tcod.path.AStar) -> None:
|
Does nothing. libtcod objects are managed by Python's garbage collector.
This function exists for backwards compatibility with libtcodpy.
|
f3112:m103
|
|
@deprecate("<STR_LIT>")<EOL>def dijkstra_delete(p: tcod.path.Dijkstra) -> None:
|
Does nothing. libtcod objects are managed by Python's garbage collector.
This function exists for backwards compatibility with libtcodpy.
|
f3112:m114
|
|
def _heightmap_cdata(array: np.ndarray) -> ffi.CData:
|
if array.flags["<STR_LIT>"]:<EOL><INDENT>array = array.transpose()<EOL><DEDENT>if not array.flags["<STR_LIT>"]:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.dtype != np.float32:<EOL><INDENT>raise ValueError("<STR_LIT>" % array.dtype)<EOL><DEDENT>width, height = array.shape<EOL>pointer = ffi.cast("<STR_LIT>", array.ctypes.data)<EOL>return ffi.new("<STR_LIT>", (width, height, pointer))<EOL>
|
Return a new TCOD_heightmap_t instance using an array.
Formatting is verified during this function.
|
f3112:m115
|
@pending_deprecate()<EOL>def heightmap_new(w: int, h: int, order: str = "<STR_LIT:C>") -> np.ndarray:
|
if order == "<STR_LIT:C>":<EOL><INDENT>return np.zeros((h, w), np.float32, order="<STR_LIT:C>")<EOL><DEDENT>elif order == "<STR_LIT:F>":<EOL><INDENT>return np.zeros((w, h), np.float32, order="<STR_LIT:F>")<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
|
Return a new numpy.ndarray formatted for use with heightmap functions.
`w` and `h` are the width and height of the array.
`order` is given to the new NumPy array, it can be 'C' or 'F'.
You can pass a NumPy array to any heightmap function as long as all the
following are true::
* The array is 2 dimensional.
* The array has the C_CONTIGUOUS or F_CONTIGUOUS flag.
* The array's dtype is :any:`dtype.float32`.
The returned NumPy array will fit all these conditions.
.. versionchanged:: 8.1
Added the `order` parameter.
|
f3112:m116
|
@deprecate("<STR_LIT>")<EOL>def heightmap_set_value(hm: np.ndarray, x: int, y: int, value: float) -> None:
|
if hm.flags["<STR_LIT>"]:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL>hm[y, x] = value<EOL><DEDENT>elif hm.flags["<STR_LIT>"]:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL>hm[x, y] = value<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
|
Set the value of a point on a heightmap.
.. deprecated:: 2.0
`hm` is a NumPy array, so values should be assigned to it directly.
|
f3112:m117
|
@deprecate("<STR_LIT>")<EOL>def heightmap_add(hm: np.ndarray, value: float) -> None:
|
hm[:] += value<EOL>
|
Add value to all values on this heightmap.
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
value (float): A number to add to this heightmap.
.. deprecated:: 2.0
Do ``hm[:] += value`` instead.
|
f3112:m118
|
@deprecate("<STR_LIT>")<EOL>def heightmap_scale(hm: np.ndarray, value: float) -> None:
|
hm[:] *= value<EOL>
|
Multiply all items on this heightmap by value.
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
value (float): A number to scale this heightmap by.
.. deprecated:: 2.0
Do ``hm[:] *= value`` instead.
|
f3112:m119
|
@deprecate("<STR_LIT>")<EOL>def heightmap_clear(hm: np.ndarray) -> None:
|
hm[:] = <NUM_LIT:0><EOL>
|
Add value to all values on this heightmap.
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
.. deprecated:: 2.0
Do ``hm.array[:] = 0`` instead.
|
f3112:m120
|
@deprecate("<STR_LIT>")<EOL>def heightmap_clamp(hm: np.ndarray, mi: float, ma: float) -> None:
|
hm.clip(mi, ma)<EOL>
|
Clamp all values on this heightmap between ``mi`` and ``ma``
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
mi (float): The lower bound to clamp to.
ma (float): The upper bound to clamp to.
.. deprecated:: 2.0
Do ``hm.clip(mi, ma)`` instead.
|
f3112:m121
|
@deprecate("<STR_LIT>")<EOL>def heightmap_copy(hm1: np.ndarray, hm2: np.ndarray) -> None:
|
hm2[:] = hm1[:]<EOL>
|
Copy the heightmap ``hm1`` to ``hm2``.
Args:
hm1 (numpy.ndarray): The source heightmap.
hm2 (numpy.ndarray): The destination heightmap.
.. deprecated:: 2.0
Do ``hm2[:] = hm1[:]`` instead.
|
f3112:m122
|
@pending_deprecate()<EOL>def heightmap_normalize(<EOL>hm: np.ndarray, mi: float = <NUM_LIT:0.0>, ma: float = <NUM_LIT:1.0><EOL>) -> None:
|
lib.TCOD_heightmap_normalize(_heightmap_cdata(hm), mi, ma)<EOL>
|
Normalize heightmap values between ``mi`` and ``ma``.
Args:
mi (float): The lowest value after normalization.
ma (float): The highest value after normalization.
|
f3112:m123
|
@pending_deprecate()<EOL>def heightmap_lerp_hm(<EOL>hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray, coef: float<EOL>) -> None:
|
lib.TCOD_heightmap_lerp_hm(<EOL>_heightmap_cdata(hm1),<EOL>_heightmap_cdata(hm2),<EOL>_heightmap_cdata(hm3),<EOL>coef,<EOL>)<EOL>
|
Perform linear interpolation between two heightmaps storing the result
in ``hm3``.
This is the same as doing ``hm3[:] = hm1[:] + (hm2[:] - hm1[:]) * coef``
Args:
hm1 (numpy.ndarray): The first heightmap.
hm2 (numpy.ndarray): The second heightmap to add to the first.
hm3 (numpy.ndarray): A destination heightmap to store the result.
coef (float): The linear interpolation coefficient.
|
f3112:m124
|
@deprecate("<STR_LIT>")<EOL>def heightmap_add_hm(<EOL>hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray<EOL>) -> None:
|
hm3[:] = hm1[:] + hm2[:]<EOL>
|
Add two heightmaps together and stores the result in ``hm3``.
Args:
hm1 (numpy.ndarray): The first heightmap.
hm2 (numpy.ndarray): The second heightmap to add to the first.
hm3 (numpy.ndarray): A destination heightmap to store the result.
.. deprecated:: 2.0
Do ``hm3[:] = hm1[:] + hm2[:]`` instead.
|
f3112:m125
|
@deprecate("<STR_LIT>")<EOL>def heightmap_multiply_hm(<EOL>hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray<EOL>) -> None:
|
hm3[:] = hm1[:] * hm2[:]<EOL>
|
Multiplies two heightmap's together and stores the result in ``hm3``.
Args:
hm1 (numpy.ndarray): The first heightmap.
hm2 (numpy.ndarray): The second heightmap to multiply with the first.
hm3 (numpy.ndarray): A destination heightmap to store the result.
.. deprecated:: 2.0
Do ``hm3[:] = hm1[:] * hm2[:]`` instead.
Alternatively you can do ``HeightMap(hm1.array[:] * hm2.array[:])``.
|
f3112:m126
|
@pending_deprecate()<EOL>def heightmap_add_hill(<EOL>hm: np.ndarray, x: float, y: float, radius: float, height: float<EOL>) -> None:
|
lib.TCOD_heightmap_add_hill(_heightmap_cdata(hm), x, y, radius, height)<EOL>
|
Add a hill (a half spheroid) at given position.
If height == radius or -radius, the hill is a half-sphere.
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
x (float): The x position at the center of the new hill.
y (float): The y position at the center of the new hill.
radius (float): The size of the new hill.
height (float): The height or depth of the new hill.
|
f3112:m127
|
@pending_deprecate()<EOL>def heightmap_dig_hill(<EOL>hm: np.ndarray, x: float, y: float, radius: float, height: float<EOL>) -> None:
|
lib.TCOD_heightmap_dig_hill(_heightmap_cdata(hm), x, y, radius, height)<EOL>
|
This function takes the highest value (if height > 0) or the lowest
(if height < 0) between the map and the hill.
It's main goal is to carve things in maps (like rivers) by digging hills
along a curve.
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
x (float): The x position at the center of the new carving.
y (float): The y position at the center of the new carving.
radius (float): The size of the carving.
height (float): The height or depth of the hill to dig out.
|
f3112:m128
|
@pending_deprecate()<EOL>def heightmap_rain_erosion(<EOL>hm: np.ndarray,<EOL>nbDrops: int,<EOL>erosionCoef: float,<EOL>sedimentationCoef: float,<EOL>rnd: Optional[tcod.random.Random] = None,<EOL>) -> None:
|
lib.TCOD_heightmap_rain_erosion(<EOL>_heightmap_cdata(hm),<EOL>nbDrops,<EOL>erosionCoef,<EOL>sedimentationCoef,<EOL>rnd.random_c if rnd else ffi.NULL,<EOL>)<EOL>
|
Simulate the effect of rain drops on the terrain, resulting in erosion.
``nbDrops`` should be at least hm.size.
Args:
hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
nbDrops (int): Number of rain drops to simulate.
erosionCoef (float): Amount of ground eroded on the drop's path.
sedimentationCoef (float): Amount of ground deposited when the drops
stops to flow.
rnd (Optional[Random]): A tcod.Random instance, or None.
|
f3112:m129
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.