id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
9,200
libtcod/python-tcod
tcod/libtcodpy.py
console_fill_char
def console_fill_char(con: tcod.console.Console, arr: Sequence[int]) -> None: """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. """ if isinstance(arr, np.ndarray): # numpy arrays, use numpy's ctypes functions np_array = np.ascontiguousarray(arr, dtype=np.intc) carr = ffi.cast("int *", np_array.ctypes.data) else: # otherwise convert using the ffi module carr = ffi.new("int[]", arr) lib.TCOD_console_fill_char(_console(con), carr)
python
def console_fill_char(con: tcod.console.Console, arr: Sequence[int]) -> None: """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. """ if isinstance(arr, np.ndarray): # numpy arrays, use numpy's ctypes functions np_array = np.ascontiguousarray(arr, dtype=np.intc) carr = ffi.cast("int *", np_array.ctypes.data) else: # otherwise convert using the ffi module carr = ffi.new("int[]", arr) lib.TCOD_console_fill_char(_console(con), carr)
[ "def", "console_fill_char", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "arr", ":", "Sequence", "[", "int", "]", ")", "->", "None", ":", "if", "isinstance", "(", "arr", ",", "np", ".", "ndarray", ")", ":", "# numpy arrays, use numpy's ctypes functions", "np_array", "=", "np", ".", "ascontiguousarray", "(", "arr", ",", "dtype", "=", "np", ".", "intc", ")", "carr", "=", "ffi", ".", "cast", "(", "\"int *\"", ",", "np_array", ".", "ctypes", ".", "data", ")", "else", ":", "# otherwise convert using the ffi module", "carr", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "arr", ")", "lib", ".", "TCOD_console_fill_char", "(", "_console", "(", "con", ")", ",", "carr", ")" ]
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.
[ "Fill", "the", "character", "tiles", "of", "a", "console", "with", "an", "array", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1857-L1874
9,201
libtcod/python-tcod
tcod/libtcodpy.py
console_load_asc
def console_load_asc(con: tcod.console.Console, filename: str) -> bool: """Update a console from a non-delimited ASCII `.asc` file.""" return bool( lib.TCOD_console_load_asc(_console(con), filename.encode("utf-8")) )
python
def console_load_asc(con: tcod.console.Console, filename: str) -> bool: """Update a console from a non-delimited ASCII `.asc` file.""" return bool( lib.TCOD_console_load_asc(_console(con), filename.encode("utf-8")) )
[ "def", "console_load_asc", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "filename", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_console_load_asc", "(", "_console", "(", "con", ")", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Update a console from a non-delimited ASCII `.asc` file.
[ "Update", "a", "console", "from", "a", "non", "-", "delimited", "ASCII", ".", "asc", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1878-L1882
9,202
libtcod/python-tcod
tcod/libtcodpy.py
console_save_asc
def console_save_asc(con: tcod.console.Console, filename: str) -> bool: """Save a console to a non-delimited ASCII `.asc` file.""" return bool( lib.TCOD_console_save_asc(_console(con), filename.encode("utf-8")) )
python
def console_save_asc(con: tcod.console.Console, filename: str) -> bool: """Save a console to a non-delimited ASCII `.asc` file.""" return bool( lib.TCOD_console_save_asc(_console(con), filename.encode("utf-8")) )
[ "def", "console_save_asc", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "filename", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_console_save_asc", "(", "_console", "(", "con", ")", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Save a console to a non-delimited ASCII `.asc` file.
[ "Save", "a", "console", "to", "a", "non", "-", "delimited", "ASCII", ".", "asc", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1886-L1890
9,203
libtcod/python-tcod
tcod/libtcodpy.py
console_load_apf
def console_load_apf(con: tcod.console.Console, filename: str) -> bool: """Update a console from an ASCII Paint `.apf` file.""" return bool( lib.TCOD_console_load_apf(_console(con), filename.encode("utf-8")) )
python
def console_load_apf(con: tcod.console.Console, filename: str) -> bool: """Update a console from an ASCII Paint `.apf` file.""" return bool( lib.TCOD_console_load_apf(_console(con), filename.encode("utf-8")) )
[ "def", "console_load_apf", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "filename", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_console_load_apf", "(", "_console", "(", "con", ")", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Update a console from an ASCII Paint `.apf` file.
[ "Update", "a", "console", "from", "an", "ASCII", "Paint", ".", "apf", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1894-L1898
9,204
libtcod/python-tcod
tcod/libtcodpy.py
console_save_apf
def console_save_apf(con: tcod.console.Console, filename: str) -> bool: """Save a console to an ASCII Paint `.apf` file.""" return bool( lib.TCOD_console_save_apf(_console(con), filename.encode("utf-8")) )
python
def console_save_apf(con: tcod.console.Console, filename: str) -> bool: """Save a console to an ASCII Paint `.apf` file.""" return bool( lib.TCOD_console_save_apf(_console(con), filename.encode("utf-8")) )
[ "def", "console_save_apf", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "filename", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_console_save_apf", "(", "_console", "(", "con", ")", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Save a console to an ASCII Paint `.apf` file.
[ "Save", "a", "console", "to", "an", "ASCII", "Paint", ".", "apf", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1902-L1906
9,205
libtcod/python-tcod
tcod/libtcodpy.py
console_load_xp
def console_load_xp(con: tcod.console.Console, filename: str) -> bool: """Update a console from a REXPaint `.xp` file.""" return bool( lib.TCOD_console_load_xp(_console(con), filename.encode("utf-8")) )
python
def console_load_xp(con: tcod.console.Console, filename: str) -> bool: """Update a console from a REXPaint `.xp` file.""" return bool( lib.TCOD_console_load_xp(_console(con), filename.encode("utf-8")) )
[ "def", "console_load_xp", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "filename", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_console_load_xp", "(", "_console", "(", "con", ")", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Update a console from a REXPaint `.xp` file.
[ "Update", "a", "console", "from", "a", "REXPaint", ".", "xp", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1909-L1913
9,206
libtcod/python-tcod
tcod/libtcodpy.py
console_save_xp
def console_save_xp( con: tcod.console.Console, filename: str, compress_level: int = 9 ) -> bool: """Save a console to a REXPaint `.xp` file.""" return bool( lib.TCOD_console_save_xp( _console(con), filename.encode("utf-8"), compress_level ) )
python
def console_save_xp( con: tcod.console.Console, filename: str, compress_level: int = 9 ) -> bool: """Save a console to a REXPaint `.xp` file.""" return bool( lib.TCOD_console_save_xp( _console(con), filename.encode("utf-8"), compress_level ) )
[ "def", "console_save_xp", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "filename", ":", "str", ",", "compress_level", ":", "int", "=", "9", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_console_save_xp", "(", "_console", "(", "con", ")", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ",", "compress_level", ")", ")" ]
Save a console to a REXPaint `.xp` file.
[ "Save", "a", "console", "to", "a", "REXPaint", ".", "xp", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1916-L1924
9,207
libtcod/python-tcod
tcod/libtcodpy.py
console_from_xp
def console_from_xp(filename: str) -> tcod.console.Console: """Return a single console from a REXPaint `.xp` file.""" return tcod.console.Console._from_cdata( lib.TCOD_console_from_xp(filename.encode("utf-8")) )
python
def console_from_xp(filename: str) -> tcod.console.Console: """Return a single console from a REXPaint `.xp` file.""" return tcod.console.Console._from_cdata( lib.TCOD_console_from_xp(filename.encode("utf-8")) )
[ "def", "console_from_xp", "(", "filename", ":", "str", ")", "->", "tcod", ".", "console", ".", "Console", ":", "return", "tcod", ".", "console", ".", "Console", ".", "_from_cdata", "(", "lib", ".", "TCOD_console_from_xp", "(", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Return a single console from a REXPaint `.xp` file.
[ "Return", "a", "single", "console", "from", "a", "REXPaint", ".", "xp", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1927-L1931
9,208
libtcod/python-tcod
tcod/libtcodpy.py
console_list_load_xp
def console_list_load_xp( filename: str ) -> Optional[List[tcod.console.Console]]: """Return a list of consoles from a REXPaint `.xp` file.""" tcod_list = lib.TCOD_console_list_from_xp(filename.encode("utf-8")) if tcod_list == ffi.NULL: return None try: python_list = [] lib.TCOD_list_reverse(tcod_list) while not lib.TCOD_list_is_empty(tcod_list): python_list.append( tcod.console.Console._from_cdata(lib.TCOD_list_pop(tcod_list)) ) return python_list finally: lib.TCOD_list_delete(tcod_list)
python
def console_list_load_xp( filename: str ) -> Optional[List[tcod.console.Console]]: """Return a list of consoles from a REXPaint `.xp` file.""" tcod_list = lib.TCOD_console_list_from_xp(filename.encode("utf-8")) if tcod_list == ffi.NULL: return None try: python_list = [] lib.TCOD_list_reverse(tcod_list) while not lib.TCOD_list_is_empty(tcod_list): python_list.append( tcod.console.Console._from_cdata(lib.TCOD_list_pop(tcod_list)) ) return python_list finally: lib.TCOD_list_delete(tcod_list)
[ "def", "console_list_load_xp", "(", "filename", ":", "str", ")", "->", "Optional", "[", "List", "[", "tcod", ".", "console", ".", "Console", "]", "]", ":", "tcod_list", "=", "lib", ".", "TCOD_console_list_from_xp", "(", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", "if", "tcod_list", "==", "ffi", ".", "NULL", ":", "return", "None", "try", ":", "python_list", "=", "[", "]", "lib", ".", "TCOD_list_reverse", "(", "tcod_list", ")", "while", "not", "lib", ".", "TCOD_list_is_empty", "(", "tcod_list", ")", ":", "python_list", ".", "append", "(", "tcod", ".", "console", ".", "Console", ".", "_from_cdata", "(", "lib", ".", "TCOD_list_pop", "(", "tcod_list", ")", ")", ")", "return", "python_list", "finally", ":", "lib", ".", "TCOD_list_delete", "(", "tcod_list", ")" ]
Return a list of consoles from a REXPaint `.xp` file.
[ "Return", "a", "list", "of", "consoles", "from", "a", "REXPaint", ".", "xp", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1934-L1950
9,209
libtcod/python-tcod
tcod/libtcodpy.py
console_list_save_xp
def console_list_save_xp( console_list: Sequence[tcod.console.Console], filename: str, compress_level: int = 9, ) -> bool: """Save a list of consoles to a REXPaint `.xp` file.""" tcod_list = lib.TCOD_list_new() try: for console in console_list: lib.TCOD_list_push(tcod_list, _console(console)) return bool( lib.TCOD_console_list_save_xp( tcod_list, filename.encode("utf-8"), compress_level ) ) finally: lib.TCOD_list_delete(tcod_list)
python
def console_list_save_xp( console_list: Sequence[tcod.console.Console], filename: str, compress_level: int = 9, ) -> bool: """Save a list of consoles to a REXPaint `.xp` file.""" tcod_list = lib.TCOD_list_new() try: for console in console_list: lib.TCOD_list_push(tcod_list, _console(console)) return bool( lib.TCOD_console_list_save_xp( tcod_list, filename.encode("utf-8"), compress_level ) ) finally: lib.TCOD_list_delete(tcod_list)
[ "def", "console_list_save_xp", "(", "console_list", ":", "Sequence", "[", "tcod", ".", "console", ".", "Console", "]", ",", "filename", ":", "str", ",", "compress_level", ":", "int", "=", "9", ",", ")", "->", "bool", ":", "tcod_list", "=", "lib", ".", "TCOD_list_new", "(", ")", "try", ":", "for", "console", "in", "console_list", ":", "lib", ".", "TCOD_list_push", "(", "tcod_list", ",", "_console", "(", "console", ")", ")", "return", "bool", "(", "lib", ".", "TCOD_console_list_save_xp", "(", "tcod_list", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ",", "compress_level", ")", ")", "finally", ":", "lib", ".", "TCOD_list_delete", "(", "tcod_list", ")" ]
Save a list of consoles to a REXPaint `.xp` file.
[ "Save", "a", "list", "of", "consoles", "to", "a", "REXPaint", ".", "xp", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1953-L1969
9,210
libtcod/python-tcod
tcod/libtcodpy.py
path_new_using_map
def path_new_using_map( m: tcod.map.Map, dcost: float = 1.41 ) -> tcod.path.AStar: """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. """ return tcod.path.AStar(m, dcost)
python
def path_new_using_map( m: tcod.map.Map, dcost: float = 1.41 ) -> tcod.path.AStar: """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. """ return tcod.path.AStar(m, dcost)
[ "def", "path_new_using_map", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "dcost", ":", "float", "=", "1.41", ")", "->", "tcod", ".", "path", ".", "AStar", ":", "return", "tcod", ".", "path", ".", "AStar", "(", "m", ",", "dcost", ")" ]
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.
[ "Return", "a", "new", "AStar", "using", "the", "given", "Map", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1973-L1985
9,211
libtcod/python-tcod
tcod/libtcodpy.py
path_new_using_function
def path_new_using_function( w: int, h: int, func: Callable[[int, int, int, int, Any], float], userData: Any = 0, dcost: float = 1.41, ) -> tcod.path.AStar: """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. """ return tcod.path.AStar( tcod.path._EdgeCostFunc((func, userData), (w, h)), dcost )
python
def path_new_using_function( w: int, h: int, func: Callable[[int, int, int, int, Any], float], userData: Any = 0, dcost: float = 1.41, ) -> tcod.path.AStar: """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. """ return tcod.path.AStar( tcod.path._EdgeCostFunc((func, userData), (w, h)), dcost )
[ "def", "path_new_using_function", "(", "w", ":", "int", ",", "h", ":", "int", ",", "func", ":", "Callable", "[", "[", "int", ",", "int", ",", "int", ",", "int", ",", "Any", "]", ",", "float", "]", ",", "userData", ":", "Any", "=", "0", ",", "dcost", ":", "float", "=", "1.41", ",", ")", "->", "tcod", ".", "path", ".", "AStar", ":", "return", "tcod", ".", "path", ".", "AStar", "(", "tcod", ".", "path", ".", "_EdgeCostFunc", "(", "(", "func", ",", "userData", ")", ",", "(", "w", ",", "h", ")", ")", ",", "dcost", ")" ]
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.
[ "Return", "a", "new", "AStar", "using", "the", "given", "callable", "function", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1989-L2010
9,212
libtcod/python-tcod
tcod/libtcodpy.py
path_get_origin
def path_get_origin(p: tcod.path.AStar) -> Tuple[int, int]: """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. """ x = ffi.new("int *") y = ffi.new("int *") lib.TCOD_path_get_origin(p._path_c, x, y) return x[0], y[0]
python
def path_get_origin(p: tcod.path.AStar) -> Tuple[int, int]: """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. """ x = ffi.new("int *") y = ffi.new("int *") lib.TCOD_path_get_origin(p._path_c, x, y) return x[0], y[0]
[ "def", "path_get_origin", "(", "p", ":", "tcod", ".", "path", ".", "AStar", ")", "->", "Tuple", "[", "int", ",", "int", "]", ":", "x", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "y", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "lib", ".", "TCOD_path_get_origin", "(", "p", ".", "_path_c", ",", "x", ",", "y", ")", "return", "x", "[", "0", "]", ",", "y", "[", "0", "]" ]
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.
[ "Get", "the", "current", "origin", "position", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2032-L2045
9,213
libtcod/python-tcod
tcod/libtcodpy.py
path_get_destination
def path_get_destination(p: tcod.path.AStar) -> Tuple[int, int]: """Get the current destination position. Args: p (AStar): An AStar instance. Returns: Tuple[int, int]: An (x, y) point. """ x = ffi.new("int *") y = ffi.new("int *") lib.TCOD_path_get_destination(p._path_c, x, y) return x[0], y[0]
python
def path_get_destination(p: tcod.path.AStar) -> Tuple[int, int]: """Get the current destination position. Args: p (AStar): An AStar instance. Returns: Tuple[int, int]: An (x, y) point. """ x = ffi.new("int *") y = ffi.new("int *") lib.TCOD_path_get_destination(p._path_c, x, y) return x[0], y[0]
[ "def", "path_get_destination", "(", "p", ":", "tcod", ".", "path", ".", "AStar", ")", "->", "Tuple", "[", "int", ",", "int", "]", ":", "x", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "y", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "lib", ".", "TCOD_path_get_destination", "(", "p", ".", "_path_c", ",", "x", ",", "y", ")", "return", "x", "[", "0", "]", ",", "y", "[", "0", "]" ]
Get the current destination position. Args: p (AStar): An AStar instance. Returns: Tuple[int, int]: An (x, y) point.
[ "Get", "the", "current", "destination", "position", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2049-L2060
9,214
libtcod/python-tcod
tcod/libtcodpy.py
path_size
def path_size(p: tcod.path.AStar) -> int: """Return the current length of the computed path. Args: p (AStar): An AStar instance. Returns: int: Length of the path. """ return int(lib.TCOD_path_size(p._path_c))
python
def path_size(p: tcod.path.AStar) -> int: """Return the current length of the computed path. Args: p (AStar): An AStar instance. Returns: int: Length of the path. """ return int(lib.TCOD_path_size(p._path_c))
[ "def", "path_size", "(", "p", ":", "tcod", ".", "path", ".", "AStar", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_path_size", "(", "p", ".", "_path_c", ")", ")" ]
Return the current length of the computed path. Args: p (AStar): An AStar instance. Returns: int: Length of the path.
[ "Return", "the", "current", "length", "of", "the", "computed", "path", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2064-L2072
9,215
libtcod/python-tcod
tcod/libtcodpy.py
path_get
def path_get(p: tcod.path.AStar, idx: int) -> Tuple[int, int]: """Get a point on a path. Args: p (AStar): An AStar instance. idx (int): Should be in range: 0 <= inx < :any:`path_size` """ x = ffi.new("int *") y = ffi.new("int *") lib.TCOD_path_get(p._path_c, idx, x, y) return x[0], y[0]
python
def path_get(p: tcod.path.AStar, idx: int) -> Tuple[int, int]: """Get a point on a path. Args: p (AStar): An AStar instance. idx (int): Should be in range: 0 <= inx < :any:`path_size` """ x = ffi.new("int *") y = ffi.new("int *") lib.TCOD_path_get(p._path_c, idx, x, y) return x[0], y[0]
[ "def", "path_get", "(", "p", ":", "tcod", ".", "path", ".", "AStar", ",", "idx", ":", "int", ")", "->", "Tuple", "[", "int", ",", "int", "]", ":", "x", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "y", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "lib", ".", "TCOD_path_get", "(", "p", ".", "_path_c", ",", "idx", ",", "x", ",", "y", ")", "return", "x", "[", "0", "]", ",", "y", "[", "0", "]" ]
Get a point on a path. Args: p (AStar): An AStar instance. idx (int): Should be in range: 0 <= inx < :any:`path_size`
[ "Get", "a", "point", "on", "a", "path", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2088-L2098
9,216
libtcod/python-tcod
tcod/libtcodpy.py
path_is_empty
def path_is_empty(p: tcod.path.AStar) -> bool: """Return True if a path is empty. Args: p (AStar): An AStar instance. Returns: bool: True if a path is empty. Otherwise False. """ return bool(lib.TCOD_path_is_empty(p._path_c))
python
def path_is_empty(p: tcod.path.AStar) -> bool: """Return True if a path is empty. Args: p (AStar): An AStar instance. Returns: bool: True if a path is empty. Otherwise False. """ return bool(lib.TCOD_path_is_empty(p._path_c))
[ "def", "path_is_empty", "(", "p", ":", "tcod", ".", "path", ".", "AStar", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_path_is_empty", "(", "p", ".", "_path_c", ")", ")" ]
Return True if a path is empty. Args: p (AStar): An AStar instance. Returns: bool: True if a path is empty. Otherwise False.
[ "Return", "True", "if", "a", "path", "is", "empty", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2102-L2110
9,217
libtcod/python-tcod
tcod/libtcodpy.py
_heightmap_cdata
def _heightmap_cdata(array: np.ndarray) -> ffi.CData: """Return a new TCOD_heightmap_t instance using an array. Formatting is verified during this function. """ if array.flags["F_CONTIGUOUS"]: array = array.transpose() if not array.flags["C_CONTIGUOUS"]: raise ValueError("array must be a contiguous segment.") if array.dtype != np.float32: raise ValueError("array dtype must be float32, not %r" % array.dtype) width, height = array.shape pointer = ffi.cast("float *", array.ctypes.data) return ffi.new("TCOD_heightmap_t *", (width, height, pointer))
python
def _heightmap_cdata(array: np.ndarray) -> ffi.CData: """Return a new TCOD_heightmap_t instance using an array. Formatting is verified during this function. """ if array.flags["F_CONTIGUOUS"]: array = array.transpose() if not array.flags["C_CONTIGUOUS"]: raise ValueError("array must be a contiguous segment.") if array.dtype != np.float32: raise ValueError("array dtype must be float32, not %r" % array.dtype) width, height = array.shape pointer = ffi.cast("float *", array.ctypes.data) return ffi.new("TCOD_heightmap_t *", (width, height, pointer))
[ "def", "_heightmap_cdata", "(", "array", ":", "np", ".", "ndarray", ")", "->", "ffi", ".", "CData", ":", "if", "array", ".", "flags", "[", "\"F_CONTIGUOUS\"", "]", ":", "array", "=", "array", ".", "transpose", "(", ")", "if", "not", "array", ".", "flags", "[", "\"C_CONTIGUOUS\"", "]", ":", "raise", "ValueError", "(", "\"array must be a contiguous segment.\"", ")", "if", "array", ".", "dtype", "!=", "np", ".", "float32", ":", "raise", "ValueError", "(", "\"array dtype must be float32, not %r\"", "%", "array", ".", "dtype", ")", "width", ",", "height", "=", "array", ".", "shape", "pointer", "=", "ffi", ".", "cast", "(", "\"float *\"", ",", "array", ".", "ctypes", ".", "data", ")", "return", "ffi", ".", "new", "(", "\"TCOD_heightmap_t *\"", ",", "(", "width", ",", "height", ",", "pointer", ")", ")" ]
Return a new TCOD_heightmap_t instance using an array. Formatting is verified during this function.
[ "Return", "a", "new", "TCOD_heightmap_t", "instance", "using", "an", "array", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2219-L2232
9,218
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_new
def heightmap_new(w: int, h: int, order: str = "C") -> np.ndarray: """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. """ if order == "C": return np.zeros((h, w), np.float32, order="C") elif order == "F": return np.zeros((w, h), np.float32, order="F") else: raise ValueError("Invalid order parameter, should be 'C' or 'F'.")
python
def heightmap_new(w: int, h: int, order: str = "C") -> np.ndarray: """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. """ if order == "C": return np.zeros((h, w), np.float32, order="C") elif order == "F": return np.zeros((w, h), np.float32, order="F") else: raise ValueError("Invalid order parameter, should be 'C' or 'F'.")
[ "def", "heightmap_new", "(", "w", ":", "int", ",", "h", ":", "int", ",", "order", ":", "str", "=", "\"C\"", ")", "->", "np", ".", "ndarray", ":", "if", "order", "==", "\"C\"", ":", "return", "np", ".", "zeros", "(", "(", "h", ",", "w", ")", ",", "np", ".", "float32", ",", "order", "=", "\"C\"", ")", "elif", "order", "==", "\"F\"", ":", "return", "np", ".", "zeros", "(", "(", "w", ",", "h", ")", ",", "np", ".", "float32", ",", "order", "=", "\"F\"", ")", "else", ":", "raise", "ValueError", "(", "\"Invalid order parameter, should be 'C' or 'F'.\"", ")" ]
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.
[ "Return", "a", "new", "numpy", ".", "ndarray", "formatted", "for", "use", "with", "heightmap", "functions", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2236-L2259
9,219
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_set_value
def heightmap_set_value(hm: np.ndarray, x: int, y: int, value: float) -> None: """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. """ if hm.flags["C_CONTIGUOUS"]: warnings.warn( "Assign to this heightmap with hm[i,j] = value\n" "consider using order='F'", DeprecationWarning, stacklevel=2, ) hm[y, x] = value elif hm.flags["F_CONTIGUOUS"]: warnings.warn( "Assign to this heightmap with hm[x,y] = value", DeprecationWarning, stacklevel=2, ) hm[x, y] = value else: raise ValueError("This array is not contiguous.")
python
def heightmap_set_value(hm: np.ndarray, x: int, y: int, value: float) -> None: """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. """ if hm.flags["C_CONTIGUOUS"]: warnings.warn( "Assign to this heightmap with hm[i,j] = value\n" "consider using order='F'", DeprecationWarning, stacklevel=2, ) hm[y, x] = value elif hm.flags["F_CONTIGUOUS"]: warnings.warn( "Assign to this heightmap with hm[x,y] = value", DeprecationWarning, stacklevel=2, ) hm[x, y] = value else: raise ValueError("This array is not contiguous.")
[ "def", "heightmap_set_value", "(", "hm", ":", "np", ".", "ndarray", ",", "x", ":", "int", ",", "y", ":", "int", ",", "value", ":", "float", ")", "->", "None", ":", "if", "hm", ".", "flags", "[", "\"C_CONTIGUOUS\"", "]", ":", "warnings", ".", "warn", "(", "\"Assign to this heightmap with hm[i,j] = value\\n\"", "\"consider using order='F'\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ",", ")", "hm", "[", "y", ",", "x", "]", "=", "value", "elif", "hm", ".", "flags", "[", "\"F_CONTIGUOUS\"", "]", ":", "warnings", ".", "warn", "(", "\"Assign to this heightmap with hm[x,y] = value\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ",", ")", "hm", "[", "x", ",", "y", "]", "=", "value", "else", ":", "raise", "ValueError", "(", "\"This array is not contiguous.\"", ")" ]
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.
[ "Set", "the", "value", "of", "a", "point", "on", "a", "heightmap", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2263-L2285
9,220
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_clamp
def heightmap_clamp(hm: np.ndarray, mi: float, ma: float) -> None: """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. """ hm.clip(mi, ma)
python
def heightmap_clamp(hm: np.ndarray, mi: float, ma: float) -> None: """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. """ hm.clip(mi, ma)
[ "def", "heightmap_clamp", "(", "hm", ":", "np", ".", "ndarray", ",", "mi", ":", "float", ",", "ma", ":", "float", ")", "->", "None", ":", "hm", ".", "clip", "(", "mi", ",", "ma", ")" ]
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.
[ "Clamp", "all", "values", "on", "this", "heightmap", "between", "mi", "and", "ma" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2330-L2341
9,221
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_normalize
def heightmap_normalize( hm: np.ndarray, mi: float = 0.0, ma: float = 1.0 ) -> None: """Normalize heightmap values between ``mi`` and ``ma``. Args: mi (float): The lowest value after normalization. ma (float): The highest value after normalization. """ lib.TCOD_heightmap_normalize(_heightmap_cdata(hm), mi, ma)
python
def heightmap_normalize( hm: np.ndarray, mi: float = 0.0, ma: float = 1.0 ) -> None: """Normalize heightmap values between ``mi`` and ``ma``. Args: mi (float): The lowest value after normalization. ma (float): The highest value after normalization. """ lib.TCOD_heightmap_normalize(_heightmap_cdata(hm), mi, ma)
[ "def", "heightmap_normalize", "(", "hm", ":", "np", ".", "ndarray", ",", "mi", ":", "float", "=", "0.0", ",", "ma", ":", "float", "=", "1.0", ")", "->", "None", ":", "lib", ".", "TCOD_heightmap_normalize", "(", "_heightmap_cdata", "(", "hm", ")", ",", "mi", ",", "ma", ")" ]
Normalize heightmap values between ``mi`` and ``ma``. Args: mi (float): The lowest value after normalization. ma (float): The highest value after normalization.
[ "Normalize", "heightmap", "values", "between", "mi", "and", "ma", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2359-L2368
9,222
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_lerp_hm
def heightmap_lerp_hm( hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray, coef: float ) -> None: """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. """ lib.TCOD_heightmap_lerp_hm( _heightmap_cdata(hm1), _heightmap_cdata(hm2), _heightmap_cdata(hm3), coef, )
python
def heightmap_lerp_hm( hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray, coef: float ) -> None: """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. """ lib.TCOD_heightmap_lerp_hm( _heightmap_cdata(hm1), _heightmap_cdata(hm2), _heightmap_cdata(hm3), coef, )
[ "def", "heightmap_lerp_hm", "(", "hm1", ":", "np", ".", "ndarray", ",", "hm2", ":", "np", ".", "ndarray", ",", "hm3", ":", "np", ".", "ndarray", ",", "coef", ":", "float", ")", "->", "None", ":", "lib", ".", "TCOD_heightmap_lerp_hm", "(", "_heightmap_cdata", "(", "hm1", ")", ",", "_heightmap_cdata", "(", "hm2", ")", ",", "_heightmap_cdata", "(", "hm3", ")", ",", "coef", ",", ")" ]
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.
[ "Perform", "linear", "interpolation", "between", "two", "heightmaps", "storing", "the", "result", "in", "hm3", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2372-L2391
9,223
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_add_hm
def heightmap_add_hm( hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray ) -> None: """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. """ hm3[:] = hm1[:] + hm2[:]
python
def heightmap_add_hm( hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray ) -> None: """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. """ hm3[:] = hm1[:] + hm2[:]
[ "def", "heightmap_add_hm", "(", "hm1", ":", "np", ".", "ndarray", ",", "hm2", ":", "np", ".", "ndarray", ",", "hm3", ":", "np", ".", "ndarray", ")", "->", "None", ":", "hm3", "[", ":", "]", "=", "hm1", "[", ":", "]", "+", "hm2", "[", ":", "]" ]
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.
[ "Add", "two", "heightmaps", "together", "and", "stores", "the", "result", "in", "hm3", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2395-L2408
9,224
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_multiply_hm
def heightmap_multiply_hm( hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray ) -> None: """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[:])``. """ hm3[:] = hm1[:] * hm2[:]
python
def heightmap_multiply_hm( hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray ) -> None: """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[:])``. """ hm3[:] = hm1[:] * hm2[:]
[ "def", "heightmap_multiply_hm", "(", "hm1", ":", "np", ".", "ndarray", ",", "hm2", ":", "np", ".", "ndarray", ",", "hm3", ":", "np", ".", "ndarray", ")", "->", "None", ":", "hm3", "[", ":", "]", "=", "hm1", "[", ":", "]", "*", "hm2", "[", ":", "]" ]
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[:])``.
[ "Multiplies", "two", "heightmap", "s", "together", "and", "stores", "the", "result", "in", "hm3", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2412-L2426
9,225
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_rain_erosion
def heightmap_rain_erosion( hm: np.ndarray, nbDrops: int, erosionCoef: float, sedimentationCoef: float, rnd: Optional[tcod.random.Random] = None, ) -> None: """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. """ lib.TCOD_heightmap_rain_erosion( _heightmap_cdata(hm), nbDrops, erosionCoef, sedimentationCoef, rnd.random_c if rnd else ffi.NULL, )
python
def heightmap_rain_erosion( hm: np.ndarray, nbDrops: int, erosionCoef: float, sedimentationCoef: float, rnd: Optional[tcod.random.Random] = None, ) -> None: """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. """ lib.TCOD_heightmap_rain_erosion( _heightmap_cdata(hm), nbDrops, erosionCoef, sedimentationCoef, rnd.random_c if rnd else ffi.NULL, )
[ "def", "heightmap_rain_erosion", "(", "hm", ":", "np", ".", "ndarray", ",", "nbDrops", ":", "int", ",", "erosionCoef", ":", "float", ",", "sedimentationCoef", ":", "float", ",", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", "=", "None", ",", ")", "->", "None", ":", "lib", ".", "TCOD_heightmap_rain_erosion", "(", "_heightmap_cdata", "(", "hm", ")", ",", "nbDrops", ",", "erosionCoef", ",", "sedimentationCoef", ",", "rnd", ".", "random_c", "if", "rnd", "else", "ffi", ".", "NULL", ",", ")" ]
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.
[ "Simulate", "the", "effect", "of", "rain", "drops", "on", "the", "terrain", "resulting", "in", "erosion", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2470-L2495
9,226
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_kernel_transform
def heightmap_kernel_transform( hm: np.ndarray, kernelsize: int, dx: Sequence[int], dy: Sequence[int], weight: Sequence[float], minLevel: float, maxLevel: float, ) -> None: """Apply a generic transformation on the map, so that each resulting cell value is the weighted sum of several neighbour cells. This can be used to smooth/sharpen the map. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. kernelsize (int): Should be set to the length of the parameters:: dx, dy, and weight. dx (Sequence[int]): A sequence of x coorinates. dy (Sequence[int]): A sequence of y coorinates. weight (Sequence[float]): A sequence of kernelSize cells weight. The value of each neighbour cell is scaled by its corresponding weight minLevel (float): No transformation will apply to cells below this value. maxLevel (float): No transformation will apply to cells above this value. See examples below for a simple horizontal smoothing kernel : replace value(x,y) with 0.33*value(x-1,y) + 0.33*value(x,y) + 0.33*value(x+1,y). To do this, you need a kernel of size 3 (the sum involves 3 surrounding cells). The dx,dy array will contain: * dx=-1, dy=0 for cell (x-1, y) * dx=1, dy=0 for cell (x+1, y) * dx=0, dy=0 for cell (x, y) * The weight array will contain 0.33 for each cell. Example: >>> import numpy as np >>> heightmap = np.zeros((3, 3), dtype=np.float32) >>> heightmap[:,1] = 1 >>> dx = [-1, 1, 0] >>> dy = [0, 0, 0] >>> weight = [0.33, 0.33, 0.33] >>> tcod.heightmap_kernel_transform(heightmap, 3, dx, dy, weight, ... 0.0, 1.0) """ cdx = ffi.new("int[]", dx) cdy = ffi.new("int[]", dy) cweight = ffi.new("float[]", weight) lib.TCOD_heightmap_kernel_transform( _heightmap_cdata(hm), kernelsize, cdx, cdy, cweight, minLevel, maxLevel )
python
def heightmap_kernel_transform( hm: np.ndarray, kernelsize: int, dx: Sequence[int], dy: Sequence[int], weight: Sequence[float], minLevel: float, maxLevel: float, ) -> None: """Apply a generic transformation on the map, so that each resulting cell value is the weighted sum of several neighbour cells. This can be used to smooth/sharpen the map. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. kernelsize (int): Should be set to the length of the parameters:: dx, dy, and weight. dx (Sequence[int]): A sequence of x coorinates. dy (Sequence[int]): A sequence of y coorinates. weight (Sequence[float]): A sequence of kernelSize cells weight. The value of each neighbour cell is scaled by its corresponding weight minLevel (float): No transformation will apply to cells below this value. maxLevel (float): No transformation will apply to cells above this value. See examples below for a simple horizontal smoothing kernel : replace value(x,y) with 0.33*value(x-1,y) + 0.33*value(x,y) + 0.33*value(x+1,y). To do this, you need a kernel of size 3 (the sum involves 3 surrounding cells). The dx,dy array will contain: * dx=-1, dy=0 for cell (x-1, y) * dx=1, dy=0 for cell (x+1, y) * dx=0, dy=0 for cell (x, y) * The weight array will contain 0.33 for each cell. Example: >>> import numpy as np >>> heightmap = np.zeros((3, 3), dtype=np.float32) >>> heightmap[:,1] = 1 >>> dx = [-1, 1, 0] >>> dy = [0, 0, 0] >>> weight = [0.33, 0.33, 0.33] >>> tcod.heightmap_kernel_transform(heightmap, 3, dx, dy, weight, ... 0.0, 1.0) """ cdx = ffi.new("int[]", dx) cdy = ffi.new("int[]", dy) cweight = ffi.new("float[]", weight) lib.TCOD_heightmap_kernel_transform( _heightmap_cdata(hm), kernelsize, cdx, cdy, cweight, minLevel, maxLevel )
[ "def", "heightmap_kernel_transform", "(", "hm", ":", "np", ".", "ndarray", ",", "kernelsize", ":", "int", ",", "dx", ":", "Sequence", "[", "int", "]", ",", "dy", ":", "Sequence", "[", "int", "]", ",", "weight", ":", "Sequence", "[", "float", "]", ",", "minLevel", ":", "float", ",", "maxLevel", ":", "float", ",", ")", "->", "None", ":", "cdx", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "dx", ")", "cdy", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "dy", ")", "cweight", "=", "ffi", ".", "new", "(", "\"float[]\"", ",", "weight", ")", "lib", ".", "TCOD_heightmap_kernel_transform", "(", "_heightmap_cdata", "(", "hm", ")", ",", "kernelsize", ",", "cdx", ",", "cdy", ",", "cweight", ",", "minLevel", ",", "maxLevel", ")" ]
Apply a generic transformation on the map, so that each resulting cell value is the weighted sum of several neighbour cells. This can be used to smooth/sharpen the map. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. kernelsize (int): Should be set to the length of the parameters:: dx, dy, and weight. dx (Sequence[int]): A sequence of x coorinates. dy (Sequence[int]): A sequence of y coorinates. weight (Sequence[float]): A sequence of kernelSize cells weight. The value of each neighbour cell is scaled by its corresponding weight minLevel (float): No transformation will apply to cells below this value. maxLevel (float): No transformation will apply to cells above this value. See examples below for a simple horizontal smoothing kernel : replace value(x,y) with 0.33*value(x-1,y) + 0.33*value(x,y) + 0.33*value(x+1,y). To do this, you need a kernel of size 3 (the sum involves 3 surrounding cells). The dx,dy array will contain: * dx=-1, dy=0 for cell (x-1, y) * dx=1, dy=0 for cell (x+1, y) * dx=0, dy=0 for cell (x, y) * The weight array will contain 0.33 for each cell. Example: >>> import numpy as np >>> heightmap = np.zeros((3, 3), dtype=np.float32) >>> heightmap[:,1] = 1 >>> dx = [-1, 1, 0] >>> dy = [0, 0, 0] >>> weight = [0.33, 0.33, 0.33] >>> tcod.heightmap_kernel_transform(heightmap, 3, dx, dy, weight, ... 0.0, 1.0)
[ "Apply", "a", "generic", "transformation", "on", "the", "map", "so", "that", "each", "resulting", "cell", "value", "is", "the", "weighted", "sum", "of", "several", "neighbour", "cells", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2499-L2554
9,227
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_add_voronoi
def heightmap_add_voronoi( hm: np.ndarray, nbPoints: Any, nbCoef: int, coef: Sequence[float], rnd: Optional[tcod.random.Random] = None, ) -> None: """Add values from a Voronoi diagram to the heightmap. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. nbPoints (Any): Number of Voronoi sites. nbCoef (int): The diagram value is calculated from the nbCoef closest sites. coef (Sequence[float]): The distance to each site is scaled by the corresponding coef. Closest site : coef[0], second closest site : coef[1], ... rnd (Optional[Random]): A Random instance, or None. """ nbPoints = len(coef) ccoef = ffi.new("float[]", coef) lib.TCOD_heightmap_add_voronoi( _heightmap_cdata(hm), nbPoints, nbCoef, ccoef, rnd.random_c if rnd else ffi.NULL, )
python
def heightmap_add_voronoi( hm: np.ndarray, nbPoints: Any, nbCoef: int, coef: Sequence[float], rnd: Optional[tcod.random.Random] = None, ) -> None: """Add values from a Voronoi diagram to the heightmap. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. nbPoints (Any): Number of Voronoi sites. nbCoef (int): The diagram value is calculated from the nbCoef closest sites. coef (Sequence[float]): The distance to each site is scaled by the corresponding coef. Closest site : coef[0], second closest site : coef[1], ... rnd (Optional[Random]): A Random instance, or None. """ nbPoints = len(coef) ccoef = ffi.new("float[]", coef) lib.TCOD_heightmap_add_voronoi( _heightmap_cdata(hm), nbPoints, nbCoef, ccoef, rnd.random_c if rnd else ffi.NULL, )
[ "def", "heightmap_add_voronoi", "(", "hm", ":", "np", ".", "ndarray", ",", "nbPoints", ":", "Any", ",", "nbCoef", ":", "int", ",", "coef", ":", "Sequence", "[", "float", "]", ",", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", "=", "None", ",", ")", "->", "None", ":", "nbPoints", "=", "len", "(", "coef", ")", "ccoef", "=", "ffi", ".", "new", "(", "\"float[]\"", ",", "coef", ")", "lib", ".", "TCOD_heightmap_add_voronoi", "(", "_heightmap_cdata", "(", "hm", ")", ",", "nbPoints", ",", "nbCoef", ",", "ccoef", ",", "rnd", ".", "random_c", "if", "rnd", "else", "ffi", ".", "NULL", ",", ")" ]
Add values from a Voronoi diagram to the heightmap. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. nbPoints (Any): Number of Voronoi sites. nbCoef (int): The diagram value is calculated from the nbCoef closest sites. coef (Sequence[float]): The distance to each site is scaled by the corresponding coef. Closest site : coef[0], second closest site : coef[1], ... rnd (Optional[Random]): A Random instance, or None.
[ "Add", "values", "from", "a", "Voronoi", "diagram", "to", "the", "heightmap", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2558-L2586
9,228
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_add_fbm
def heightmap_add_fbm( hm: np.ndarray, noise: tcod.noise.Noise, mulx: float, muly: float, addx: float, addy: float, octaves: float, delta: float, scale: float, ) -> None: """Add FBM noise to the heightmap. The noise coordinate for each map cell is `((x + addx) * mulx / width, (y + addy) * muly / height)`. The value added to the heightmap is `delta + noise * scale`. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. noise (Noise): A Noise instance. mulx (float): Scaling of each x coordinate. muly (float): Scaling of each y coordinate. addx (float): Translation of each x coordinate. addy (float): Translation of each y coordinate. octaves (float): Number of octaves in the FBM sum. delta (float): The value added to all heightmap cells. scale (float): The noise value is scaled with this parameter. .. deprecated:: 8.1 An equivalent array of noise samples can be taken using a method such as :any:`Noise.sample_ogrid`. """ noise = noise.noise_c if noise is not None else ffi.NULL lib.TCOD_heightmap_add_fbm( _heightmap_cdata(hm), noise, mulx, muly, addx, addy, octaves, delta, scale, )
python
def heightmap_add_fbm( hm: np.ndarray, noise: tcod.noise.Noise, mulx: float, muly: float, addx: float, addy: float, octaves: float, delta: float, scale: float, ) -> None: """Add FBM noise to the heightmap. The noise coordinate for each map cell is `((x + addx) * mulx / width, (y + addy) * muly / height)`. The value added to the heightmap is `delta + noise * scale`. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. noise (Noise): A Noise instance. mulx (float): Scaling of each x coordinate. muly (float): Scaling of each y coordinate. addx (float): Translation of each x coordinate. addy (float): Translation of each y coordinate. octaves (float): Number of octaves in the FBM sum. delta (float): The value added to all heightmap cells. scale (float): The noise value is scaled with this parameter. .. deprecated:: 8.1 An equivalent array of noise samples can be taken using a method such as :any:`Noise.sample_ogrid`. """ noise = noise.noise_c if noise is not None else ffi.NULL lib.TCOD_heightmap_add_fbm( _heightmap_cdata(hm), noise, mulx, muly, addx, addy, octaves, delta, scale, )
[ "def", "heightmap_add_fbm", "(", "hm", ":", "np", ".", "ndarray", ",", "noise", ":", "tcod", ".", "noise", ".", "Noise", ",", "mulx", ":", "float", ",", "muly", ":", "float", ",", "addx", ":", "float", ",", "addy", ":", "float", ",", "octaves", ":", "float", ",", "delta", ":", "float", ",", "scale", ":", "float", ",", ")", "->", "None", ":", "noise", "=", "noise", ".", "noise_c", "if", "noise", "is", "not", "None", "else", "ffi", ".", "NULL", "lib", ".", "TCOD_heightmap_add_fbm", "(", "_heightmap_cdata", "(", "hm", ")", ",", "noise", ",", "mulx", ",", "muly", ",", "addx", ",", "addy", ",", "octaves", ",", "delta", ",", "scale", ",", ")" ]
Add FBM noise to the heightmap. The noise coordinate for each map cell is `((x + addx) * mulx / width, (y + addy) * muly / height)`. The value added to the heightmap is `delta + noise * scale`. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. noise (Noise): A Noise instance. mulx (float): Scaling of each x coordinate. muly (float): Scaling of each y coordinate. addx (float): Translation of each x coordinate. addy (float): Translation of each y coordinate. octaves (float): Number of octaves in the FBM sum. delta (float): The value added to all heightmap cells. scale (float): The noise value is scaled with this parameter. .. deprecated:: 8.1 An equivalent array of noise samples can be taken using a method such as :any:`Noise.sample_ogrid`.
[ "Add", "FBM", "noise", "to", "the", "heightmap", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2590-L2634
9,229
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_dig_bezier
def heightmap_dig_bezier( hm: np.ndarray, px: Tuple[int, int, int, int], py: Tuple[int, int, int, int], startRadius: float, startDepth: float, endRadius: float, endDepth: float, ) -> None: """Carve a path along a cubic Bezier curve. Both radius and depth can vary linearly along the path. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. px (Sequence[int]): The 4 `x` coordinates of the Bezier curve. py (Sequence[int]): The 4 `y` coordinates of the Bezier curve. startRadius (float): The starting radius size. startDepth (float): The starting depth. endRadius (float): The ending radius size. endDepth (float): The ending depth. """ lib.TCOD_heightmap_dig_bezier( _heightmap_cdata(hm), px, py, startRadius, startDepth, endRadius, endDepth, )
python
def heightmap_dig_bezier( hm: np.ndarray, px: Tuple[int, int, int, int], py: Tuple[int, int, int, int], startRadius: float, startDepth: float, endRadius: float, endDepth: float, ) -> None: """Carve a path along a cubic Bezier curve. Both radius and depth can vary linearly along the path. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. px (Sequence[int]): The 4 `x` coordinates of the Bezier curve. py (Sequence[int]): The 4 `y` coordinates of the Bezier curve. startRadius (float): The starting radius size. startDepth (float): The starting depth. endRadius (float): The ending radius size. endDepth (float): The ending depth. """ lib.TCOD_heightmap_dig_bezier( _heightmap_cdata(hm), px, py, startRadius, startDepth, endRadius, endDepth, )
[ "def", "heightmap_dig_bezier", "(", "hm", ":", "np", ".", "ndarray", ",", "px", ":", "Tuple", "[", "int", ",", "int", ",", "int", ",", "int", "]", ",", "py", ":", "Tuple", "[", "int", ",", "int", ",", "int", ",", "int", "]", ",", "startRadius", ":", "float", ",", "startDepth", ":", "float", ",", "endRadius", ":", "float", ",", "endDepth", ":", "float", ",", ")", "->", "None", ":", "lib", ".", "TCOD_heightmap_dig_bezier", "(", "_heightmap_cdata", "(", "hm", ")", ",", "px", ",", "py", ",", "startRadius", ",", "startDepth", ",", "endRadius", ",", "endDepth", ",", ")" ]
Carve a path along a cubic Bezier curve. Both radius and depth can vary linearly along the path. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. px (Sequence[int]): The 4 `x` coordinates of the Bezier curve. py (Sequence[int]): The 4 `y` coordinates of the Bezier curve. startRadius (float): The starting radius size. startDepth (float): The starting depth. endRadius (float): The ending radius size. endDepth (float): The ending depth.
[ "Carve", "a", "path", "along", "a", "cubic", "Bezier", "curve", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2681-L2711
9,230
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_get_interpolated_value
def heightmap_get_interpolated_value( hm: np.ndarray, x: float, y: float ) -> float: """Return the interpolated height at non integer coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): A floating point x coordinate. y (float): A floating point y coordinate. Returns: float: The value at ``x``, ``y``. """ return float( lib.TCOD_heightmap_get_interpolated_value(_heightmap_cdata(hm), x, y) )
python
def heightmap_get_interpolated_value( hm: np.ndarray, x: float, y: float ) -> float: """Return the interpolated height at non integer coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): A floating point x coordinate. y (float): A floating point y coordinate. Returns: float: The value at ``x``, ``y``. """ return float( lib.TCOD_heightmap_get_interpolated_value(_heightmap_cdata(hm), x, y) )
[ "def", "heightmap_get_interpolated_value", "(", "hm", ":", "np", ".", "ndarray", ",", "x", ":", "float", ",", "y", ":", "float", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_heightmap_get_interpolated_value", "(", "_heightmap_cdata", "(", "hm", ")", ",", "x", ",", "y", ")", ")" ]
Return the interpolated height at non integer coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): A floating point x coordinate. y (float): A floating point y coordinate. Returns: float: The value at ``x``, ``y``.
[ "Return", "the", "interpolated", "height", "at", "non", "integer", "coordinates", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2741-L2756
9,231
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_get_normal
def heightmap_get_normal( hm: np.ndarray, x: float, y: float, waterLevel: float ) -> Tuple[float, float, float]: """Return the map normal at given coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): The x coordinate. y (float): The y coordinate. waterLevel (float): The heightmap is considered flat below this value. Returns: Tuple[float, float, float]: An (x, y, z) vector normal. """ cn = ffi.new("float[3]") lib.TCOD_heightmap_get_normal(_heightmap_cdata(hm), x, y, cn, waterLevel) return tuple(cn)
python
def heightmap_get_normal( hm: np.ndarray, x: float, y: float, waterLevel: float ) -> Tuple[float, float, float]: """Return the map normal at given coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): The x coordinate. y (float): The y coordinate. waterLevel (float): The heightmap is considered flat below this value. Returns: Tuple[float, float, float]: An (x, y, z) vector normal. """ cn = ffi.new("float[3]") lib.TCOD_heightmap_get_normal(_heightmap_cdata(hm), x, y, cn, waterLevel) return tuple(cn)
[ "def", "heightmap_get_normal", "(", "hm", ":", "np", ".", "ndarray", ",", "x", ":", "float", ",", "y", ":", "float", ",", "waterLevel", ":", "float", ")", "->", "Tuple", "[", "float", ",", "float", ",", "float", "]", ":", "cn", "=", "ffi", ".", "new", "(", "\"float[3]\"", ")", "lib", ".", "TCOD_heightmap_get_normal", "(", "_heightmap_cdata", "(", "hm", ")", ",", "x", ",", "y", ",", "cn", ",", "waterLevel", ")", "return", "tuple", "(", "cn", ")" ]
Return the map normal at given coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): The x coordinate. y (float): The y coordinate. waterLevel (float): The heightmap is considered flat below this value. Returns: Tuple[float, float, float]: An (x, y, z) vector normal.
[ "Return", "the", "map", "normal", "at", "given", "coordinates", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2775-L2791
9,232
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_count_cells
def heightmap_count_cells(hm: np.ndarray, mi: float, ma: float) -> int: """Return the number of map cells which value is between ``mi`` and ``ma``. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. mi (float): The lower bound. ma (float): The upper bound. Returns: int: The count of values which fall between ``mi`` and ``ma``. .. deprecated:: 8.1 Can be replaced by an equivalent NumPy function such as: ``numpy.count_nonzero((mi <= hm) & (hm < ma))`` """ return int(lib.TCOD_heightmap_count_cells(_heightmap_cdata(hm), mi, ma))
python
def heightmap_count_cells(hm: np.ndarray, mi: float, ma: float) -> int: """Return the number of map cells which value is between ``mi`` and ``ma``. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. mi (float): The lower bound. ma (float): The upper bound. Returns: int: The count of values which fall between ``mi`` and ``ma``. .. deprecated:: 8.1 Can be replaced by an equivalent NumPy function such as: ``numpy.count_nonzero((mi <= hm) & (hm < ma))`` """ return int(lib.TCOD_heightmap_count_cells(_heightmap_cdata(hm), mi, ma))
[ "def", "heightmap_count_cells", "(", "hm", ":", "np", ".", "ndarray", ",", "mi", ":", "float", ",", "ma", ":", "float", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_heightmap_count_cells", "(", "_heightmap_cdata", "(", "hm", ")", ",", "mi", ",", "ma", ")", ")" ]
Return the number of map cells which value is between ``mi`` and ``ma``. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. mi (float): The lower bound. ma (float): The upper bound. Returns: int: The count of values which fall between ``mi`` and ``ma``. .. deprecated:: 8.1 Can be replaced by an equivalent NumPy function such as: ``numpy.count_nonzero((mi <= hm) & (hm < ma))``
[ "Return", "the", "number", "of", "map", "cells", "which", "value", "is", "between", "mi", "and", "ma", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2795-L2810
9,233
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_has_land_on_border
def heightmap_has_land_on_border(hm: np.ndarray, waterlevel: float) -> bool: """Returns True if the map edges are below ``waterlevel``, otherwise False. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. waterLevel (float): The water level to use. Returns: bool: True if the map edges are below ``waterlevel``, otherwise False. """ return bool( lib.TCOD_heightmap_has_land_on_border(_heightmap_cdata(hm), waterlevel) )
python
def heightmap_has_land_on_border(hm: np.ndarray, waterlevel: float) -> bool: """Returns True if the map edges are below ``waterlevel``, otherwise False. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. waterLevel (float): The water level to use. Returns: bool: True if the map edges are below ``waterlevel``, otherwise False. """ return bool( lib.TCOD_heightmap_has_land_on_border(_heightmap_cdata(hm), waterlevel) )
[ "def", "heightmap_has_land_on_border", "(", "hm", ":", "np", ".", "ndarray", ",", "waterlevel", ":", "float", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_heightmap_has_land_on_border", "(", "_heightmap_cdata", "(", "hm", ")", ",", "waterlevel", ")", ")" ]
Returns True if the map edges are below ``waterlevel``, otherwise False. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. waterLevel (float): The water level to use. Returns: bool: True if the map edges are below ``waterlevel``, otherwise False.
[ "Returns", "True", "if", "the", "map", "edges", "are", "below", "waterlevel", "otherwise", "False", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2814-L2826
9,234
libtcod/python-tcod
tcod/libtcodpy.py
heightmap_get_minmax
def heightmap_get_minmax(hm: np.ndarray) -> Tuple[float, float]: """Return the min and max values of this heightmap. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. Returns: Tuple[float, float]: The (min, max) values. .. deprecated:: 2.0 Use ``hm.min()`` or ``hm.max()`` instead. """ mi = ffi.new("float *") ma = ffi.new("float *") lib.TCOD_heightmap_get_minmax(_heightmap_cdata(hm), mi, ma) return mi[0], ma[0]
python
def heightmap_get_minmax(hm: np.ndarray) -> Tuple[float, float]: """Return the min and max values of this heightmap. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. Returns: Tuple[float, float]: The (min, max) values. .. deprecated:: 2.0 Use ``hm.min()`` or ``hm.max()`` instead. """ mi = ffi.new("float *") ma = ffi.new("float *") lib.TCOD_heightmap_get_minmax(_heightmap_cdata(hm), mi, ma) return mi[0], ma[0]
[ "def", "heightmap_get_minmax", "(", "hm", ":", "np", ".", "ndarray", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "mi", "=", "ffi", ".", "new", "(", "\"float *\"", ")", "ma", "=", "ffi", ".", "new", "(", "\"float *\"", ")", "lib", ".", "TCOD_heightmap_get_minmax", "(", "_heightmap_cdata", "(", "hm", ")", ",", "mi", ",", "ma", ")", "return", "mi", "[", "0", "]", ",", "ma", "[", "0", "]" ]
Return the min and max values of this heightmap. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. Returns: Tuple[float, float]: The (min, max) values. .. deprecated:: 2.0 Use ``hm.min()`` or ``hm.max()`` instead.
[ "Return", "the", "min", "and", "max", "values", "of", "this", "heightmap", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2830-L2845
9,235
libtcod/python-tcod
tcod/libtcodpy.py
image_load
def image_load(filename: str) -> tcod.image.Image: """Load an image file into an Image instance and return it. Args: filename (AnyStr): Path to a .bmp or .png image file. """ return tcod.image.Image._from_cdata( ffi.gc(lib.TCOD_image_load(_bytes(filename)), lib.TCOD_image_delete) )
python
def image_load(filename: str) -> tcod.image.Image: """Load an image file into an Image instance and return it. Args: filename (AnyStr): Path to a .bmp or .png image file. """ return tcod.image.Image._from_cdata( ffi.gc(lib.TCOD_image_load(_bytes(filename)), lib.TCOD_image_delete) )
[ "def", "image_load", "(", "filename", ":", "str", ")", "->", "tcod", ".", "image", ".", "Image", ":", "return", "tcod", ".", "image", ".", "Image", ".", "_from_cdata", "(", "ffi", ".", "gc", "(", "lib", ".", "TCOD_image_load", "(", "_bytes", "(", "filename", ")", ")", ",", "lib", ".", "TCOD_image_delete", ")", ")" ]
Load an image file into an Image instance and return it. Args: filename (AnyStr): Path to a .bmp or .png image file.
[ "Load", "an", "image", "file", "into", "an", "Image", "instance", "and", "return", "it", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2914-L2922
9,236
libtcod/python-tcod
tcod/libtcodpy.py
image_from_console
def image_from_console(console: tcod.console.Console) -> tcod.image.Image: """Return an Image with a Consoles pixel data. This effectively takes a screen-shot of the Console. Args: console (Console): Any Console instance. """ return tcod.image.Image._from_cdata( ffi.gc( lib.TCOD_image_from_console(_console(console)), lib.TCOD_image_delete, ) )
python
def image_from_console(console: tcod.console.Console) -> tcod.image.Image: """Return an Image with a Consoles pixel data. This effectively takes a screen-shot of the Console. Args: console (Console): Any Console instance. """ return tcod.image.Image._from_cdata( ffi.gc( lib.TCOD_image_from_console(_console(console)), lib.TCOD_image_delete, ) )
[ "def", "image_from_console", "(", "console", ":", "tcod", ".", "console", ".", "Console", ")", "->", "tcod", ".", "image", ".", "Image", ":", "return", "tcod", ".", "image", ".", "Image", ".", "_from_cdata", "(", "ffi", ".", "gc", "(", "lib", ".", "TCOD_image_from_console", "(", "_console", "(", "console", ")", ")", ",", "lib", ".", "TCOD_image_delete", ",", ")", ")" ]
Return an Image with a Consoles pixel data. This effectively takes a screen-shot of the Console. Args: console (Console): Any Console instance.
[ "Return", "an", "Image", "with", "a", "Consoles", "pixel", "data", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2926-L2939
9,237
libtcod/python-tcod
tcod/libtcodpy.py
line_init
def line_init(xo: int, yo: int, xd: int, yd: int) -> None: """Initilize a line whose points will be returned by `line_step`. This function does not return anything on its own. Does not include the origin point. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. .. deprecated:: 2.0 Use `line_iter` instead. """ lib.TCOD_line_init(xo, yo, xd, yd)
python
def line_init(xo: int, yo: int, xd: int, yd: int) -> None: """Initilize a line whose points will be returned by `line_step`. This function does not return anything on its own. Does not include the origin point. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. .. deprecated:: 2.0 Use `line_iter` instead. """ lib.TCOD_line_init(xo, yo, xd, yd)
[ "def", "line_init", "(", "xo", ":", "int", ",", "yo", ":", "int", ",", "xd", ":", "int", ",", "yd", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_line_init", "(", "xo", ",", "yo", ",", "xd", ",", "yd", ")" ]
Initilize a line whose points will be returned by `line_step`. This function does not return anything on its own. Does not include the origin point. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. .. deprecated:: 2.0 Use `line_iter` instead.
[ "Initilize", "a", "line", "whose", "points", "will", "be", "returned", "by", "line_step", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3030-L3046
9,238
libtcod/python-tcod
tcod/libtcodpy.py
line
def line( xo: int, yo: int, xd: int, yd: int, py_callback: Callable[[int, int], bool] ) -> bool: """ Iterate over a line using a callback function. Your callback function will take x and y parameters and return True to continue iteration or False to stop iteration and return. This function includes both the start and end points. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. py_callback (Callable[[int, int], bool]): A callback which takes x and y parameters and returns bool. Returns: bool: False if the callback cancels the line interation by returning False or None, otherwise True. .. deprecated:: 2.0 Use `line_iter` instead. """ for x, y in line_iter(xo, yo, xd, yd): if not py_callback(x, y): break else: return True return False
python
def line( xo: int, yo: int, xd: int, yd: int, py_callback: Callable[[int, int], bool] ) -> bool: """ Iterate over a line using a callback function. Your callback function will take x and y parameters and return True to continue iteration or False to stop iteration and return. This function includes both the start and end points. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. py_callback (Callable[[int, int], bool]): A callback which takes x and y parameters and returns bool. Returns: bool: False if the callback cancels the line interation by returning False or None, otherwise True. .. deprecated:: 2.0 Use `line_iter` instead. """ for x, y in line_iter(xo, yo, xd, yd): if not py_callback(x, y): break else: return True return False
[ "def", "line", "(", "xo", ":", "int", ",", "yo", ":", "int", ",", "xd", ":", "int", ",", "yd", ":", "int", ",", "py_callback", ":", "Callable", "[", "[", "int", ",", "int", "]", ",", "bool", "]", ")", "->", "bool", ":", "for", "x", ",", "y", "in", "line_iter", "(", "xo", ",", "yo", ",", "xd", ",", "yd", ")", ":", "if", "not", "py_callback", "(", "x", ",", "y", ")", ":", "break", "else", ":", "return", "True", "return", "False" ]
Iterate over a line using a callback function. Your callback function will take x and y parameters and return True to continue iteration or False to stop iteration and return. This function includes both the start and end points. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. py_callback (Callable[[int, int], bool]): A callback which takes x and y parameters and returns bool. Returns: bool: False if the callback cancels the line interation by returning False or None, otherwise True. .. deprecated:: 2.0 Use `line_iter` instead.
[ "Iterate", "over", "a", "line", "using", "a", "callback", "function", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3072-L3102
9,239
libtcod/python-tcod
tcod/libtcodpy.py
line_iter
def line_iter(xo: int, yo: int, xd: int, yd: int) -> Iterator[Tuple[int, int]]: """ returns an Iterable This Iterable does not include the origin point. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. Returns: Iterable[Tuple[int,int]]: An Iterable of (x,y) points. """ data = ffi.new("TCOD_bresenham_data_t *") lib.TCOD_line_init_mt(xo, yo, xd, yd, data) x = ffi.new("int *") y = ffi.new("int *") yield xo, yo while not lib.TCOD_line_step_mt(x, y, data): yield (x[0], y[0])
python
def line_iter(xo: int, yo: int, xd: int, yd: int) -> Iterator[Tuple[int, int]]: """ returns an Iterable This Iterable does not include the origin point. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. Returns: Iterable[Tuple[int,int]]: An Iterable of (x,y) points. """ data = ffi.new("TCOD_bresenham_data_t *") lib.TCOD_line_init_mt(xo, yo, xd, yd, data) x = ffi.new("int *") y = ffi.new("int *") yield xo, yo while not lib.TCOD_line_step_mt(x, y, data): yield (x[0], y[0])
[ "def", "line_iter", "(", "xo", ":", "int", ",", "yo", ":", "int", ",", "xd", ":", "int", ",", "yd", ":", "int", ")", "->", "Iterator", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "data", "=", "ffi", ".", "new", "(", "\"TCOD_bresenham_data_t *\"", ")", "lib", ".", "TCOD_line_init_mt", "(", "xo", ",", "yo", ",", "xd", ",", "yd", ",", "data", ")", "x", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "y", "=", "ffi", ".", "new", "(", "\"int *\"", ")", "yield", "xo", ",", "yo", "while", "not", "lib", ".", "TCOD_line_step_mt", "(", "x", ",", "y", ",", "data", ")", ":", "yield", "(", "x", "[", "0", "]", ",", "y", "[", "0", "]", ")" ]
returns an Iterable This Iterable does not include the origin point. Args: xo (int): X starting point. yo (int): Y starting point. xd (int): X destination point. yd (int): Y destination point. Returns: Iterable[Tuple[int,int]]: An Iterable of (x,y) points.
[ "returns", "an", "Iterable" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3105-L3125
9,240
libtcod/python-tcod
tcod/libtcodpy.py
line_where
def line_where( x1: int, y1: int, x2: int, y2: int, inclusive: bool = True ) -> Tuple[np.array, np.array]: """Return a NumPy index array following a Bresenham line. If `inclusive` is true then the start point is included in the result. Example: >>> where = tcod.line_where(1, 0, 3, 4) >>> where (array([1, 1, 2, 2, 3]...), array([0, 1, 2, 3, 4]...)) >>> array = np.zeros((5, 5), dtype=np.int32) >>> array[where] = np.arange(len(where[0])) + 1 >>> array array([[0, 0, 0, 0, 0], [1, 2, 0, 0, 0], [0, 0, 3, 4, 0], [0, 0, 0, 0, 5], [0, 0, 0, 0, 0]]...) .. versionadded:: 4.6 """ length = max(abs(x1 - x2), abs(y1 - y2)) + 1 array = np.ndarray((2, length), dtype=np.intc) x = ffi.cast("int*", array[0].ctypes.data) y = ffi.cast("int*", array[1].ctypes.data) lib.LineWhere(x1, y1, x2, y2, x, y) if not inclusive: array = array[:, 1:] return tuple(array)
python
def line_where( x1: int, y1: int, x2: int, y2: int, inclusive: bool = True ) -> Tuple[np.array, np.array]: """Return a NumPy index array following a Bresenham line. If `inclusive` is true then the start point is included in the result. Example: >>> where = tcod.line_where(1, 0, 3, 4) >>> where (array([1, 1, 2, 2, 3]...), array([0, 1, 2, 3, 4]...)) >>> array = np.zeros((5, 5), dtype=np.int32) >>> array[where] = np.arange(len(where[0])) + 1 >>> array array([[0, 0, 0, 0, 0], [1, 2, 0, 0, 0], [0, 0, 3, 4, 0], [0, 0, 0, 0, 5], [0, 0, 0, 0, 0]]...) .. versionadded:: 4.6 """ length = max(abs(x1 - x2), abs(y1 - y2)) + 1 array = np.ndarray((2, length), dtype=np.intc) x = ffi.cast("int*", array[0].ctypes.data) y = ffi.cast("int*", array[1].ctypes.data) lib.LineWhere(x1, y1, x2, y2, x, y) if not inclusive: array = array[:, 1:] return tuple(array)
[ "def", "line_where", "(", "x1", ":", "int", ",", "y1", ":", "int", ",", "x2", ":", "int", ",", "y2", ":", "int", ",", "inclusive", ":", "bool", "=", "True", ")", "->", "Tuple", "[", "np", ".", "array", ",", "np", ".", "array", "]", ":", "length", "=", "max", "(", "abs", "(", "x1", "-", "x2", ")", ",", "abs", "(", "y1", "-", "y2", ")", ")", "+", "1", "array", "=", "np", ".", "ndarray", "(", "(", "2", ",", "length", ")", ",", "dtype", "=", "np", ".", "intc", ")", "x", "=", "ffi", ".", "cast", "(", "\"int*\"", ",", "array", "[", "0", "]", ".", "ctypes", ".", "data", ")", "y", "=", "ffi", ".", "cast", "(", "\"int*\"", ",", "array", "[", "1", "]", ".", "ctypes", ".", "data", ")", "lib", ".", "LineWhere", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "x", ",", "y", ")", "if", "not", "inclusive", ":", "array", "=", "array", "[", ":", ",", "1", ":", "]", "return", "tuple", "(", "array", ")" ]
Return a NumPy index array following a Bresenham line. If `inclusive` is true then the start point is included in the result. Example: >>> where = tcod.line_where(1, 0, 3, 4) >>> where (array([1, 1, 2, 2, 3]...), array([0, 1, 2, 3, 4]...)) >>> array = np.zeros((5, 5), dtype=np.int32) >>> array[where] = np.arange(len(where[0])) + 1 >>> array array([[0, 0, 0, 0, 0], [1, 2, 0, 0, 0], [0, 0, 3, 4, 0], [0, 0, 0, 0, 5], [0, 0, 0, 0, 0]]...) .. versionadded:: 4.6
[ "Return", "a", "NumPy", "index", "array", "following", "a", "Bresenham", "line", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3128-L3157
9,241
libtcod/python-tcod
tcod/libtcodpy.py
map_copy
def map_copy(source: tcod.map.Map, dest: tcod.map.Map) -> None: """Copy map data from `source` to `dest`. .. deprecated:: 4.5 Use Python's copy module, or see :any:`tcod.map.Map` and assign between array attributes manually. """ if source.width != dest.width or source.height != dest.height: dest.__init__( # type: ignore source.width, source.height, source._order ) dest._Map__buffer[:] = source._Map__buffer[:]
python
def map_copy(source: tcod.map.Map, dest: tcod.map.Map) -> None: """Copy map data from `source` to `dest`. .. deprecated:: 4.5 Use Python's copy module, or see :any:`tcod.map.Map` and assign between array attributes manually. """ if source.width != dest.width or source.height != dest.height: dest.__init__( # type: ignore source.width, source.height, source._order ) dest._Map__buffer[:] = source._Map__buffer[:]
[ "def", "map_copy", "(", "source", ":", "tcod", ".", "map", ".", "Map", ",", "dest", ":", "tcod", ".", "map", ".", "Map", ")", "->", "None", ":", "if", "source", ".", "width", "!=", "dest", ".", "width", "or", "source", ".", "height", "!=", "dest", ".", "height", ":", "dest", ".", "__init__", "(", "# type: ignore", "source", ".", "width", ",", "source", ".", "height", ",", "source", ".", "_order", ")", "dest", ".", "_Map__buffer", "[", ":", "]", "=", "source", ".", "_Map__buffer", "[", ":", "]" ]
Copy map data from `source` to `dest`. .. deprecated:: 4.5 Use Python's copy module, or see :any:`tcod.map.Map` and assign between array attributes manually.
[ "Copy", "map", "data", "from", "source", "to", "dest", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3172-L3183
9,242
libtcod/python-tcod
tcod/libtcodpy.py
map_set_properties
def map_set_properties( m: tcod.map.Map, x: int, y: int, isTrans: bool, isWalk: bool ) -> None: """Set the properties of a single cell. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties. """ lib.TCOD_map_set_properties(m.map_c, x, y, isTrans, isWalk)
python
def map_set_properties( m: tcod.map.Map, x: int, y: int, isTrans: bool, isWalk: bool ) -> None: """Set the properties of a single cell. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties. """ lib.TCOD_map_set_properties(m.map_c, x, y, isTrans, isWalk)
[ "def", "map_set_properties", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "x", ":", "int", ",", "y", ":", "int", ",", "isTrans", ":", "bool", ",", "isWalk", ":", "bool", ")", "->", "None", ":", "lib", ".", "TCOD_map_set_properties", "(", "m", ".", "map_c", ",", "x", ",", "y", ",", "isTrans", ",", "isWalk", ")" ]
Set the properties of a single cell. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties.
[ "Set", "the", "properties", "of", "a", "single", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3187-L3198
9,243
libtcod/python-tcod
tcod/libtcodpy.py
map_clear
def map_clear( m: tcod.map.Map, transparent: bool = False, walkable: bool = False ) -> None: """Change all map cells to a specific value. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties. """ m.transparent[:] = transparent m.walkable[:] = walkable
python
def map_clear( m: tcod.map.Map, transparent: bool = False, walkable: bool = False ) -> None: """Change all map cells to a specific value. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties. """ m.transparent[:] = transparent m.walkable[:] = walkable
[ "def", "map_clear", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "transparent", ":", "bool", "=", "False", ",", "walkable", ":", "bool", "=", "False", ")", "->", "None", ":", "m", ".", "transparent", "[", ":", "]", "=", "transparent", "m", ".", "walkable", "[", ":", "]", "=", "walkable" ]
Change all map cells to a specific value. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties.
[ "Change", "all", "map", "cells", "to", "a", "specific", "value", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3202-L3212
9,244
libtcod/python-tcod
tcod/libtcodpy.py
map_compute_fov
def map_compute_fov( m: tcod.map.Map, x: int, y: int, radius: int = 0, light_walls: bool = True, algo: int = FOV_RESTRICTIVE, ) -> None: """Compute the field-of-view for a map instance. .. deprecated:: 4.5 Use :any:`tcod.map.Map.compute_fov` instead. """ m.compute_fov(x, y, radius, light_walls, algo)
python
def map_compute_fov( m: tcod.map.Map, x: int, y: int, radius: int = 0, light_walls: bool = True, algo: int = FOV_RESTRICTIVE, ) -> None: """Compute the field-of-view for a map instance. .. deprecated:: 4.5 Use :any:`tcod.map.Map.compute_fov` instead. """ m.compute_fov(x, y, radius, light_walls, algo)
[ "def", "map_compute_fov", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "x", ":", "int", ",", "y", ":", "int", ",", "radius", ":", "int", "=", "0", ",", "light_walls", ":", "bool", "=", "True", ",", "algo", ":", "int", "=", "FOV_RESTRICTIVE", ",", ")", "->", "None", ":", "m", ".", "compute_fov", "(", "x", ",", "y", ",", "radius", ",", "light_walls", ",", "algo", ")" ]
Compute the field-of-view for a map instance. .. deprecated:: 4.5 Use :any:`tcod.map.Map.compute_fov` instead.
[ "Compute", "the", "field", "-", "of", "-", "view", "for", "a", "map", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3216-L3229
9,245
libtcod/python-tcod
tcod/libtcodpy.py
map_is_in_fov
def map_is_in_fov(m: tcod.map.Map, x: int, y: int) -> bool: """Return True if the cell at x,y is lit by the last field-of-view algorithm. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.fov` to check this property. """ return bool(lib.TCOD_map_is_in_fov(m.map_c, x, y))
python
def map_is_in_fov(m: tcod.map.Map, x: int, y: int) -> bool: """Return True if the cell at x,y is lit by the last field-of-view algorithm. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.fov` to check this property. """ return bool(lib.TCOD_map_is_in_fov(m.map_c, x, y))
[ "def", "map_is_in_fov", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_map_is_in_fov", "(", "m", ".", "map_c", ",", "x", ",", "y", ")", ")" ]
Return True if the cell at x,y is lit by the last field-of-view algorithm. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.fov` to check this property.
[ "Return", "True", "if", "the", "cell", "at", "x", "y", "is", "lit", "by", "the", "last", "field", "-", "of", "-", "view", "algorithm", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3233-L3242
9,246
libtcod/python-tcod
tcod/libtcodpy.py
noise_new
def noise_new( dim: int, h: float = NOISE_DEFAULT_HURST, l: float = NOISE_DEFAULT_LACUNARITY, # noqa: E741 random: Optional[tcod.random.Random] = None, ) -> tcod.noise.Noise: """Return a new Noise instance. Args: dim (int): Number of dimensions. From 1 to 4. h (float): The hurst exponent. Should be in the 0.0-1.0 range. l (float): The noise lacunarity. random (Optional[Random]): A Random instance, or None. Returns: Noise: The new Noise instance. """ return tcod.noise.Noise(dim, hurst=h, lacunarity=l, seed=random)
python
def noise_new( dim: int, h: float = NOISE_DEFAULT_HURST, l: float = NOISE_DEFAULT_LACUNARITY, # noqa: E741 random: Optional[tcod.random.Random] = None, ) -> tcod.noise.Noise: """Return a new Noise instance. Args: dim (int): Number of dimensions. From 1 to 4. h (float): The hurst exponent. Should be in the 0.0-1.0 range. l (float): The noise lacunarity. random (Optional[Random]): A Random instance, or None. Returns: Noise: The new Noise instance. """ return tcod.noise.Noise(dim, hurst=h, lacunarity=l, seed=random)
[ "def", "noise_new", "(", "dim", ":", "int", ",", "h", ":", "float", "=", "NOISE_DEFAULT_HURST", ",", "l", ":", "float", "=", "NOISE_DEFAULT_LACUNARITY", ",", "# noqa: E741", "random", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", "=", "None", ",", ")", "->", "tcod", ".", "noise", ".", "Noise", ":", "return", "tcod", ".", "noise", ".", "Noise", "(", "dim", ",", "hurst", "=", "h", ",", "lacunarity", "=", "l", ",", "seed", "=", "random", ")" ]
Return a new Noise instance. Args: dim (int): Number of dimensions. From 1 to 4. h (float): The hurst exponent. Should be in the 0.0-1.0 range. l (float): The noise lacunarity. random (Optional[Random]): A Random instance, or None. Returns: Noise: The new Noise instance.
[ "Return", "a", "new", "Noise", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3356-L3373
9,247
libtcod/python-tcod
tcod/libtcodpy.py
noise_set_type
def noise_set_type(n: tcod.noise.Noise, typ: int) -> None: """Set a Noise objects default noise algorithm. Args: typ (int): Any NOISE_* constant. """ n.algorithm = typ
python
def noise_set_type(n: tcod.noise.Noise, typ: int) -> None: """Set a Noise objects default noise algorithm. Args: typ (int): Any NOISE_* constant. """ n.algorithm = typ
[ "def", "noise_set_type", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "typ", ":", "int", ")", "->", "None", ":", "n", ".", "algorithm", "=", "typ" ]
Set a Noise objects default noise algorithm. Args: typ (int): Any NOISE_* constant.
[ "Set", "a", "Noise", "objects", "default", "noise", "algorithm", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3377-L3383
9,248
libtcod/python-tcod
tcod/libtcodpy.py
noise_get
def noise_get( n: tcod.noise.Noise, f: Sequence[float], typ: int = NOISE_DEFAULT ) -> float: """Return the noise value sampled from the ``f`` coordinate. ``f`` should be a tuple or list with a length matching :any:`Noise.dimensions`. If ``f`` is shoerter than :any:`Noise.dimensions` the missing coordinates will be filled with zeros. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. Returns: float: The sampled noise value. """ return float(lib.TCOD_noise_get_ex(n.noise_c, ffi.new("float[4]", f), typ))
python
def noise_get( n: tcod.noise.Noise, f: Sequence[float], typ: int = NOISE_DEFAULT ) -> float: """Return the noise value sampled from the ``f`` coordinate. ``f`` should be a tuple or list with a length matching :any:`Noise.dimensions`. If ``f`` is shoerter than :any:`Noise.dimensions` the missing coordinates will be filled with zeros. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. Returns: float: The sampled noise value. """ return float(lib.TCOD_noise_get_ex(n.noise_c, ffi.new("float[4]", f), typ))
[ "def", "noise_get", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "f", ":", "Sequence", "[", "float", "]", ",", "typ", ":", "int", "=", "NOISE_DEFAULT", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_noise_get_ex", "(", "n", ".", "noise_c", ",", "ffi", ".", "new", "(", "\"float[4]\"", ",", "f", ")", ",", "typ", ")", ")" ]
Return the noise value sampled from the ``f`` coordinate. ``f`` should be a tuple or list with a length matching :any:`Noise.dimensions`. If ``f`` is shoerter than :any:`Noise.dimensions` the missing coordinates will be filled with zeros. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. Returns: float: The sampled noise value.
[ "Return", "the", "noise", "value", "sampled", "from", "the", "f", "coordinate", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3387-L3405
9,249
libtcod/python-tcod
tcod/libtcodpy.py
noise_get_fbm
def noise_get_fbm( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float: The sampled noise value. """ return float( lib.TCOD_noise_get_fbm_ex(n.noise_c, ffi.new("float[4]", f), oc, typ) )
python
def noise_get_fbm( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float: The sampled noise value. """ return float( lib.TCOD_noise_get_fbm_ex(n.noise_c, ffi.new("float[4]", f), oc, typ) )
[ "def", "noise_get_fbm", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "f", ":", "Sequence", "[", "float", "]", ",", "oc", ":", "float", ",", "typ", ":", "int", "=", "NOISE_DEFAULT", ",", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_noise_get_fbm_ex", "(", "n", ".", "noise_c", ",", "ffi", ".", "new", "(", "\"float[4]\"", ",", "f", ")", ",", "oc", ",", "typ", ")", ")" ]
Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float: The sampled noise value.
[ "Return", "the", "fractal", "Brownian", "motion", "sampled", "from", "the", "f", "coordinate", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3409-L3428
9,250
libtcod/python-tcod
tcod/libtcodpy.py
noise_get_turbulence
def noise_get_turbulence( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the turbulence noise sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float: The sampled noise value. """ return float( lib.TCOD_noise_get_turbulence_ex( n.noise_c, ffi.new("float[4]", f), oc, typ ) )
python
def noise_get_turbulence( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the turbulence noise sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float: The sampled noise value. """ return float( lib.TCOD_noise_get_turbulence_ex( n.noise_c, ffi.new("float[4]", f), oc, typ ) )
[ "def", "noise_get_turbulence", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "f", ":", "Sequence", "[", "float", "]", ",", "oc", ":", "float", ",", "typ", ":", "int", "=", "NOISE_DEFAULT", ",", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_noise_get_turbulence_ex", "(", "n", ".", "noise_c", ",", "ffi", ".", "new", "(", "\"float[4]\"", ",", "f", ")", ",", "oc", ",", "typ", ")", ")" ]
Return the turbulence noise sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float: The sampled noise value.
[ "Return", "the", "turbulence", "noise", "sampled", "from", "the", "f", "coordinate", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3432-L3453
9,251
libtcod/python-tcod
tcod/libtcodpy.py
random_get_instance
def random_get_instance() -> tcod.random.Random: """Return the default Random instance. Returns: Random: A Random instance using the default random number generator. """ return tcod.random.Random._new_from_cdata( ffi.cast("mersenne_data_t*", lib.TCOD_random_get_instance()) )
python
def random_get_instance() -> tcod.random.Random: """Return the default Random instance. Returns: Random: A Random instance using the default random number generator. """ return tcod.random.Random._new_from_cdata( ffi.cast("mersenne_data_t*", lib.TCOD_random_get_instance()) )
[ "def", "random_get_instance", "(", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", ".", "_new_from_cdata", "(", "ffi", ".", "cast", "(", "\"mersenne_data_t*\"", ",", "lib", ".", "TCOD_random_get_instance", "(", ")", ")", ")" ]
Return the default Random instance. Returns: Random: A Random instance using the default random number generator.
[ "Return", "the", "default", "Random", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3635-L3643
9,252
libtcod/python-tcod
tcod/libtcodpy.py
random_new
def random_new(algo: int = RNG_CMWC) -> tcod.random.Random: """Return a new Random instance. Using ``algo``. Args: algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm. """ return tcod.random.Random(algo)
python
def random_new(algo: int = RNG_CMWC) -> tcod.random.Random: """Return a new Random instance. Using ``algo``. Args: algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm. """ return tcod.random.Random(algo)
[ "def", "random_new", "(", "algo", ":", "int", "=", "RNG_CMWC", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", "(", "algo", ")" ]
Return a new Random instance. Using ``algo``. Args: algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm.
[ "Return", "a", "new", "Random", "instance", ".", "Using", "algo", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3647-L3656
9,253
libtcod/python-tcod
tcod/libtcodpy.py
random_new_from_seed
def random_new_from_seed( seed: Hashable, algo: int = RNG_CMWC ) -> tcod.random.Random: """Return a new Random instance. Using the given ``seed`` and ``algo``. Args: seed (Hashable): The RNG seed. Should be a 32-bit integer, but any hashable object is accepted. algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm. """ return tcod.random.Random(algo, seed)
python
def random_new_from_seed( seed: Hashable, algo: int = RNG_CMWC ) -> tcod.random.Random: """Return a new Random instance. Using the given ``seed`` and ``algo``. Args: seed (Hashable): The RNG seed. Should be a 32-bit integer, but any hashable object is accepted. algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm. """ return tcod.random.Random(algo, seed)
[ "def", "random_new_from_seed", "(", "seed", ":", "Hashable", ",", "algo", ":", "int", "=", "RNG_CMWC", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", "(", "algo", ",", "seed", ")" ]
Return a new Random instance. Using the given ``seed`` and ``algo``. Args: seed (Hashable): The RNG seed. Should be a 32-bit integer, but any hashable object is accepted. algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm.
[ "Return", "a", "new", "Random", "instance", ".", "Using", "the", "given", "seed", "and", "algo", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3660-L3673
9,254
libtcod/python-tcod
tcod/libtcodpy.py
random_set_distribution
def random_set_distribution( rnd: Optional[tcod.random.Random], dist: int ) -> None: """Change the distribution mode of a random number generator. Args: rnd (Optional[Random]): A Random instance, or None to use the default. dist (int): The distribution mode to use. Should be DISTRIBUTION_*. """ lib.TCOD_random_set_distribution(rnd.random_c if rnd else ffi.NULL, dist)
python
def random_set_distribution( rnd: Optional[tcod.random.Random], dist: int ) -> None: """Change the distribution mode of a random number generator. Args: rnd (Optional[Random]): A Random instance, or None to use the default. dist (int): The distribution mode to use. Should be DISTRIBUTION_*. """ lib.TCOD_random_set_distribution(rnd.random_c if rnd else ffi.NULL, dist)
[ "def", "random_set_distribution", "(", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", ",", "dist", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_random_set_distribution", "(", "rnd", ".", "random_c", "if", "rnd", "else", "ffi", ".", "NULL", ",", "dist", ")" ]
Change the distribution mode of a random number generator. Args: rnd (Optional[Random]): A Random instance, or None to use the default. dist (int): The distribution mode to use. Should be DISTRIBUTION_*.
[ "Change", "the", "distribution", "mode", "of", "a", "random", "number", "generator", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3677-L3686
9,255
libtcod/python-tcod
tcod/libtcodpy.py
random_save
def random_save(rnd: Optional[tcod.random.Random]) -> tcod.random.Random: """Return a copy of a random number generator. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state. """ return tcod.random.Random._new_from_cdata( ffi.gc( ffi.cast( "mersenne_data_t*", lib.TCOD_random_save(rnd.random_c if rnd else ffi.NULL), ), lib.TCOD_random_delete, ) )
python
def random_save(rnd: Optional[tcod.random.Random]) -> tcod.random.Random: """Return a copy of a random number generator. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state. """ return tcod.random.Random._new_from_cdata( ffi.gc( ffi.cast( "mersenne_data_t*", lib.TCOD_random_save(rnd.random_c if rnd else ffi.NULL), ), lib.TCOD_random_delete, ) )
[ "def", "random_save", "(", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", ".", "_new_from_cdata", "(", "ffi", ".", "gc", "(", "ffi", ".", "cast", "(", "\"mersenne_data_t*\"", ",", "lib", ".", "TCOD_random_save", "(", "rnd", ".", "random_c", "if", "rnd", "else", "ffi", ".", "NULL", ")", ",", ")", ",", "lib", ".", "TCOD_random_delete", ",", ")", ")" ]
Return a copy of a random number generator. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state.
[ "Return", "a", "copy", "of", "a", "random", "number", "generator", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3812-L3827
9,256
libtcod/python-tcod
tcod/libtcodpy.py
random_restore
def random_restore( rnd: Optional[tcod.random.Random], backup: tcod.random.Random ) -> None: """Restore a random number generator from a backed up copy. Args: rnd (Optional[Random]): A Random instance, or None to use the default. backup (Random): The Random instance which was used as a backup. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state. """ lib.TCOD_random_restore(rnd.random_c if rnd else ffi.NULL, backup.random_c)
python
def random_restore( rnd: Optional[tcod.random.Random], backup: tcod.random.Random ) -> None: """Restore a random number generator from a backed up copy. Args: rnd (Optional[Random]): A Random instance, or None to use the default. backup (Random): The Random instance which was used as a backup. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state. """ lib.TCOD_random_restore(rnd.random_c if rnd else ffi.NULL, backup.random_c)
[ "def", "random_restore", "(", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", ",", "backup", ":", "tcod", ".", "random", ".", "Random", ")", "->", "None", ":", "lib", ".", "TCOD_random_restore", "(", "rnd", ".", "random_c", "if", "rnd", "else", "ffi", ".", "NULL", ",", "backup", ".", "random_c", ")" ]
Restore a random number generator from a backed up copy. Args: rnd (Optional[Random]): A Random instance, or None to use the default. backup (Random): The Random instance which was used as a backup. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state.
[ "Restore", "a", "random", "number", "generator", "from", "a", "backed", "up", "copy", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3831-L3844
9,257
libtcod/python-tcod
tcod/libtcodpy.py
sys_set_renderer
def sys_set_renderer(renderer: int) -> None: """Change the current rendering mode to renderer. .. deprecated:: 2.0 RENDERER_GLSL and RENDERER_OPENGL are not currently available. """ lib.TCOD_sys_set_renderer(renderer) if tcod.console._root_console is not None: tcod.console.Console._get_root()
python
def sys_set_renderer(renderer: int) -> None: """Change the current rendering mode to renderer. .. deprecated:: 2.0 RENDERER_GLSL and RENDERER_OPENGL are not currently available. """ lib.TCOD_sys_set_renderer(renderer) if tcod.console._root_console is not None: tcod.console.Console._get_root()
[ "def", "sys_set_renderer", "(", "renderer", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_sys_set_renderer", "(", "renderer", ")", "if", "tcod", ".", "console", ".", "_root_console", "is", "not", "None", ":", "tcod", ".", "console", ".", "Console", ".", "_get_root", "(", ")" ]
Change the current rendering mode to renderer. .. deprecated:: 2.0 RENDERER_GLSL and RENDERER_OPENGL are not currently available.
[ "Change", "the", "current", "rendering", "mode", "to", "renderer", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3973-L3981
9,258
libtcod/python-tcod
tcod/libtcodpy.py
sys_save_screenshot
def sys_save_screenshot(name: Optional[str] = None) -> None: """Save a screenshot to a file. By default this will automatically save screenshots in the working directory. The automatic names are formatted as screenshotNNN.png. For example: screenshot000.png, screenshot001.png, etc. Whichever is available first. Args: file Optional[AnyStr]: File path to save screenshot. """ lib.TCOD_sys_save_screenshot( _bytes(name) if name is not None else ffi.NULL )
python
def sys_save_screenshot(name: Optional[str] = None) -> None: """Save a screenshot to a file. By default this will automatically save screenshots in the working directory. The automatic names are formatted as screenshotNNN.png. For example: screenshot000.png, screenshot001.png, etc. Whichever is available first. Args: file Optional[AnyStr]: File path to save screenshot. """ lib.TCOD_sys_save_screenshot( _bytes(name) if name is not None else ffi.NULL )
[ "def", "sys_save_screenshot", "(", "name", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "lib", ".", "TCOD_sys_save_screenshot", "(", "_bytes", "(", "name", ")", "if", "name", "is", "not", "None", "else", "ffi", ".", "NULL", ")" ]
Save a screenshot to a file. By default this will automatically save screenshots in the working directory. The automatic names are formatted as screenshotNNN.png. For example: screenshot000.png, screenshot001.png, etc. Whichever is available first. Args: file Optional[AnyStr]: File path to save screenshot.
[ "Save", "a", "screenshot", "to", "a", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3992-L4006
9,259
libtcod/python-tcod
tcod/libtcodpy.py
sys_update_char
def sys_update_char( asciiCode: int, fontx: int, fonty: int, img: tcod.image.Image, x: int, y: int, ) -> None: """Dynamically update the current font with img. All cells using this asciiCode will be updated at the next call to :any:`tcod.console_flush`. Args: asciiCode (int): Ascii code corresponding to the character to update. fontx (int): Left coordinate of the character in the bitmap font (in tiles) fonty (int): Top coordinate of the character in the bitmap font (in tiles) img (Image): An image containing the new character bitmap. x (int): Left pixel of the character in the image. y (int): Top pixel of the character in the image. """ lib.TCOD_sys_update_char(_int(asciiCode), fontx, fonty, img, x, y)
python
def sys_update_char( asciiCode: int, fontx: int, fonty: int, img: tcod.image.Image, x: int, y: int, ) -> None: """Dynamically update the current font with img. All cells using this asciiCode will be updated at the next call to :any:`tcod.console_flush`. Args: asciiCode (int): Ascii code corresponding to the character to update. fontx (int): Left coordinate of the character in the bitmap font (in tiles) fonty (int): Top coordinate of the character in the bitmap font (in tiles) img (Image): An image containing the new character bitmap. x (int): Left pixel of the character in the image. y (int): Top pixel of the character in the image. """ lib.TCOD_sys_update_char(_int(asciiCode), fontx, fonty, img, x, y)
[ "def", "sys_update_char", "(", "asciiCode", ":", "int", ",", "fontx", ":", "int", ",", "fonty", ":", "int", ",", "img", ":", "tcod", ".", "image", ".", "Image", ",", "x", ":", "int", ",", "y", ":", "int", ",", ")", "->", "None", ":", "lib", ".", "TCOD_sys_update_char", "(", "_int", "(", "asciiCode", ")", ",", "fontx", ",", "fonty", ",", "img", ",", "x", ",", "y", ")" ]
Dynamically update the current font with img. All cells using this asciiCode will be updated at the next call to :any:`tcod.console_flush`. Args: asciiCode (int): Ascii code corresponding to the character to update. fontx (int): Left coordinate of the character in the bitmap font (in tiles) fonty (int): Top coordinate of the character in the bitmap font (in tiles) img (Image): An image containing the new character bitmap. x (int): Left pixel of the character in the image. y (int): Top pixel of the character in the image.
[ "Dynamically", "update", "the", "current", "font", "with", "img", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4054-L4077
9,260
libtcod/python-tcod
tcod/libtcodpy.py
sys_register_SDL_renderer
def sys_register_SDL_renderer(callback: Callable[[Any], None]) -> None: """Register a custom randering function with libtcod. Note: This callback will only be called by the SDL renderer. The callack will receive a :any:`CData <ffi-cdata>` void* to an SDL_Surface* struct. The callback is called on every call to :any:`tcod.console_flush`. Args: callback Callable[[CData], None]: A function which takes a single argument. """ with _PropagateException() as propagate: @ffi.def_extern(onerror=propagate) # type: ignore def _pycall_sdl_hook(sdl_surface: Any) -> None: callback(sdl_surface) lib.TCOD_sys_register_SDL_renderer(lib._pycall_sdl_hook)
python
def sys_register_SDL_renderer(callback: Callable[[Any], None]) -> None: """Register a custom randering function with libtcod. Note: This callback will only be called by the SDL renderer. The callack will receive a :any:`CData <ffi-cdata>` void* to an SDL_Surface* struct. The callback is called on every call to :any:`tcod.console_flush`. Args: callback Callable[[CData], None]: A function which takes a single argument. """ with _PropagateException() as propagate: @ffi.def_extern(onerror=propagate) # type: ignore def _pycall_sdl_hook(sdl_surface: Any) -> None: callback(sdl_surface) lib.TCOD_sys_register_SDL_renderer(lib._pycall_sdl_hook)
[ "def", "sys_register_SDL_renderer", "(", "callback", ":", "Callable", "[", "[", "Any", "]", ",", "None", "]", ")", "->", "None", ":", "with", "_PropagateException", "(", ")", "as", "propagate", ":", "@", "ffi", ".", "def_extern", "(", "onerror", "=", "propagate", ")", "# type: ignore", "def", "_pycall_sdl_hook", "(", "sdl_surface", ":", "Any", ")", "->", "None", ":", "callback", "(", "sdl_surface", ")", "lib", ".", "TCOD_sys_register_SDL_renderer", "(", "lib", ".", "_pycall_sdl_hook", ")" ]
Register a custom randering function with libtcod. Note: This callback will only be called by the SDL renderer. The callack will receive a :any:`CData <ffi-cdata>` void* to an SDL_Surface* struct. The callback is called on every call to :any:`tcod.console_flush`. Args: callback Callable[[CData], None]: A function which takes a single argument.
[ "Register", "a", "custom", "randering", "function", "with", "libtcod", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4081-L4102
9,261
libtcod/python-tcod
tcod/libtcodpy.py
sys_check_for_event
def sys_check_for_event( mask: int, k: Optional[Key], m: Optional[Mouse] ) -> int: """Check for and return an event. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated with an event. Can be None. .. deprecated:: 9.3 Use the :any:`tcod.event.get` function to check for events. """ return int( lib.TCOD_sys_check_for_event( mask, k.key_p if k else ffi.NULL, m.mouse_p if m else ffi.NULL ) )
python
def sys_check_for_event( mask: int, k: Optional[Key], m: Optional[Mouse] ) -> int: """Check for and return an event. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated with an event. Can be None. .. deprecated:: 9.3 Use the :any:`tcod.event.get` function to check for events. """ return int( lib.TCOD_sys_check_for_event( mask, k.key_p if k else ffi.NULL, m.mouse_p if m else ffi.NULL ) )
[ "def", "sys_check_for_event", "(", "mask", ":", "int", ",", "k", ":", "Optional", "[", "Key", "]", ",", "m", ":", "Optional", "[", "Mouse", "]", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_sys_check_for_event", "(", "mask", ",", "k", ".", "key_p", "if", "k", "else", "ffi", ".", "NULL", ",", "m", ".", "mouse_p", "if", "m", "else", "ffi", ".", "NULL", ")", ")" ]
Check for and return an event. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated with an event. Can be None. .. deprecated:: 9.3 Use the :any:`tcod.event.get` function to check for events.
[ "Check", "for", "and", "return", "an", "event", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4106-L4125
9,262
libtcod/python-tcod
tcod/libtcodpy.py
sys_wait_for_event
def sys_wait_for_event( mask: int, k: Optional[Key], m: Optional[Mouse], flush: bool ) -> int: """Wait for an event then return. If flush is True then the buffer will be cleared before waiting. Otherwise each available event will be returned in the order they're recieved. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated with an event. Can be None. flush (bool): Clear the event buffer before waiting. .. deprecated:: 9.3 Use the :any:`tcod.event.wait` function to wait for events. """ return int( lib.TCOD_sys_wait_for_event( mask, k.key_p if k else ffi.NULL, m.mouse_p if m else ffi.NULL, flush, ) )
python
def sys_wait_for_event( mask: int, k: Optional[Key], m: Optional[Mouse], flush: bool ) -> int: """Wait for an event then return. If flush is True then the buffer will be cleared before waiting. Otherwise each available event will be returned in the order they're recieved. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated with an event. Can be None. flush (bool): Clear the event buffer before waiting. .. deprecated:: 9.3 Use the :any:`tcod.event.wait` function to wait for events. """ return int( lib.TCOD_sys_wait_for_event( mask, k.key_p if k else ffi.NULL, m.mouse_p if m else ffi.NULL, flush, ) )
[ "def", "sys_wait_for_event", "(", "mask", ":", "int", ",", "k", ":", "Optional", "[", "Key", "]", ",", "m", ":", "Optional", "[", "Mouse", "]", ",", "flush", ":", "bool", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_sys_wait_for_event", "(", "mask", ",", "k", ".", "key_p", "if", "k", "else", "ffi", ".", "NULL", ",", "m", ".", "mouse_p", "if", "m", "else", "ffi", ".", "NULL", ",", "flush", ",", ")", ")" ]
Wait for an event then return. If flush is True then the buffer will be cleared before waiting. Otherwise each available event will be returned in the order they're recieved. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated with an event. Can be None. flush (bool): Clear the event buffer before waiting. .. deprecated:: 9.3 Use the :any:`tcod.event.wait` function to wait for events.
[ "Wait", "for", "an", "event", "then", "return", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4129-L4155
9,263
libtcod/python-tcod
tcod/libtcodpy.py
_atexit_verify
def _atexit_verify() -> None: """Warns if the libtcod root console is implicitly deleted.""" if lib.TCOD_ctx.root: warnings.warn( "The libtcod root console was implicitly deleted.\n" "Make sure the 'with' statement is used with the root console to" " ensure that it closes properly.", ResourceWarning, stacklevel=2, ) lib.TCOD_console_delete(ffi.NULL)
python
def _atexit_verify() -> None: """Warns if the libtcod root console is implicitly deleted.""" if lib.TCOD_ctx.root: warnings.warn( "The libtcod root console was implicitly deleted.\n" "Make sure the 'with' statement is used with the root console to" " ensure that it closes properly.", ResourceWarning, stacklevel=2, ) lib.TCOD_console_delete(ffi.NULL)
[ "def", "_atexit_verify", "(", ")", "->", "None", ":", "if", "lib", ".", "TCOD_ctx", ".", "root", ":", "warnings", ".", "warn", "(", "\"The libtcod root console was implicitly deleted.\\n\"", "\"Make sure the 'with' statement is used with the root console to\"", "\" ensure that it closes properly.\"", ",", "ResourceWarning", ",", "stacklevel", "=", "2", ",", ")", "lib", ".", "TCOD_console_delete", "(", "ffi", ".", "NULL", ")" ]
Warns if the libtcod root console is implicitly deleted.
[ "Warns", "if", "the", "libtcod", "root", "console", "is", "implicitly", "deleted", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4179-L4189
9,264
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.clear
def clear( self, back_r: int = 0, back_g: int = 0, back_b: int = 0, fore_r: int = 0, fore_g: int = 0, fore_b: int = 0, char: str = " ", ) -> None: """Clears the console. Values to fill it with are optional, defaults to black with no characters. Args: back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. fore_r (int): Red foreground color, from 0 to 255. fore_g (int): Green foreground color, from 0 to 255. fore_b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object. """ n = self.width * self.height self.back_r = [back_r] * n self.back_g = [back_g] * n self.back_b = [back_b] * n self.fore_r = [fore_r] * n self.fore_g = [fore_g] * n self.fore_b = [fore_b] * n self.char = [ord(char)] * n
python
def clear( self, back_r: int = 0, back_g: int = 0, back_b: int = 0, fore_r: int = 0, fore_g: int = 0, fore_b: int = 0, char: str = " ", ) -> None: """Clears the console. Values to fill it with are optional, defaults to black with no characters. Args: back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. fore_r (int): Red foreground color, from 0 to 255. fore_g (int): Green foreground color, from 0 to 255. fore_b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object. """ n = self.width * self.height self.back_r = [back_r] * n self.back_g = [back_g] * n self.back_b = [back_b] * n self.fore_r = [fore_r] * n self.fore_g = [fore_g] * n self.fore_b = [fore_b] * n self.char = [ord(char)] * n
[ "def", "clear", "(", "self", ",", "back_r", ":", "int", "=", "0", ",", "back_g", ":", "int", "=", "0", ",", "back_b", ":", "int", "=", "0", ",", "fore_r", ":", "int", "=", "0", ",", "fore_g", ":", "int", "=", "0", ",", "fore_b", ":", "int", "=", "0", ",", "char", ":", "str", "=", "\" \"", ",", ")", "->", "None", ":", "n", "=", "self", ".", "width", "*", "self", ".", "height", "self", ".", "back_r", "=", "[", "back_r", "]", "*", "n", "self", ".", "back_g", "=", "[", "back_g", "]", "*", "n", "self", ".", "back_b", "=", "[", "back_b", "]", "*", "n", "self", ".", "fore_r", "=", "[", "fore_r", "]", "*", "n", "self", ".", "fore_g", "=", "[", "fore_g", "]", "*", "n", "self", ".", "fore_b", "=", "[", "fore_b", "]", "*", "n", "self", ".", "char", "=", "[", "ord", "(", "char", ")", "]", "*", "n" ]
Clears the console. Values to fill it with are optional, defaults to black with no characters. Args: back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. fore_r (int): Red foreground color, from 0 to 255. fore_g (int): Green foreground color, from 0 to 255. fore_b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object.
[ "Clears", "the", "console", ".", "Values", "to", "fill", "it", "with", "are", "optional", "defaults", "to", "black", "with", "no", "characters", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L120-L149
9,265
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.copy
def copy(self) -> "ConsoleBuffer": """Returns a copy of this ConsoleBuffer. Returns: ConsoleBuffer: A new ConsoleBuffer copy. """ other = ConsoleBuffer(0, 0) # type: "ConsoleBuffer" other.width = self.width other.height = self.height other.back_r = list(self.back_r) # make explicit copies of all lists other.back_g = list(self.back_g) other.back_b = list(self.back_b) other.fore_r = list(self.fore_r) other.fore_g = list(self.fore_g) other.fore_b = list(self.fore_b) other.char = list(self.char) return other
python
def copy(self) -> "ConsoleBuffer": """Returns a copy of this ConsoleBuffer. Returns: ConsoleBuffer: A new ConsoleBuffer copy. """ other = ConsoleBuffer(0, 0) # type: "ConsoleBuffer" other.width = self.width other.height = self.height other.back_r = list(self.back_r) # make explicit copies of all lists other.back_g = list(self.back_g) other.back_b = list(self.back_b) other.fore_r = list(self.fore_r) other.fore_g = list(self.fore_g) other.fore_b = list(self.fore_b) other.char = list(self.char) return other
[ "def", "copy", "(", "self", ")", "->", "\"ConsoleBuffer\"", ":", "other", "=", "ConsoleBuffer", "(", "0", ",", "0", ")", "# type: \"ConsoleBuffer\"", "other", ".", "width", "=", "self", ".", "width", "other", ".", "height", "=", "self", ".", "height", "other", ".", "back_r", "=", "list", "(", "self", ".", "back_r", ")", "# make explicit copies of all lists", "other", ".", "back_g", "=", "list", "(", "self", ".", "back_g", ")", "other", ".", "back_b", "=", "list", "(", "self", ".", "back_b", ")", "other", ".", "fore_r", "=", "list", "(", "self", ".", "fore_r", ")", "other", ".", "fore_g", "=", "list", "(", "self", ".", "fore_g", ")", "other", ".", "fore_b", "=", "list", "(", "self", ".", "fore_b", ")", "other", ".", "char", "=", "list", "(", "self", ".", "char", ")", "return", "other" ]
Returns a copy of this ConsoleBuffer. Returns: ConsoleBuffer: A new ConsoleBuffer copy.
[ "Returns", "a", "copy", "of", "this", "ConsoleBuffer", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L151-L167
9,266
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.set_fore
def set_fore( self, x: int, y: int, r: int, g: int, b: int, char: str ) -> None: """Set the character and foreground color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red foreground color, from 0 to 255. g (int): Green foreground color, from 0 to 255. b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object. """ i = self.width * y + x self.fore_r[i] = r self.fore_g[i] = g self.fore_b[i] = b self.char[i] = ord(char)
python
def set_fore( self, x: int, y: int, r: int, g: int, b: int, char: str ) -> None: """Set the character and foreground color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red foreground color, from 0 to 255. g (int): Green foreground color, from 0 to 255. b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object. """ i = self.width * y + x self.fore_r[i] = r self.fore_g[i] = g self.fore_b[i] = b self.char[i] = ord(char)
[ "def", "set_fore", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ",", "char", ":", "str", ")", "->", "None", ":", "i", "=", "self", ".", "width", "*", "y", "+", "x", "self", ".", "fore_r", "[", "i", "]", "=", "r", "self", ".", "fore_g", "[", "i", "]", "=", "g", "self", ".", "fore_b", "[", "i", "]", "=", "b", "self", ".", "char", "[", "i", "]", "=", "ord", "(", "char", ")" ]
Set the character and foreground color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red foreground color, from 0 to 255. g (int): Green foreground color, from 0 to 255. b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object.
[ "Set", "the", "character", "and", "foreground", "color", "of", "one", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L169-L186
9,267
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.set_back
def set_back(self, x: int, y: int, r: int, g: int, b: int) -> None: """Set the background color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red background color, from 0 to 255. g (int): Green background color, from 0 to 255. b (int): Blue background color, from 0 to 255. """ i = self.width * y + x self.back_r[i] = r self.back_g[i] = g self.back_b[i] = b
python
def set_back(self, x: int, y: int, r: int, g: int, b: int) -> None: """Set the background color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red background color, from 0 to 255. g (int): Green background color, from 0 to 255. b (int): Blue background color, from 0 to 255. """ i = self.width * y + x self.back_r[i] = r self.back_g[i] = g self.back_b[i] = b
[ "def", "set_back", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "None", ":", "i", "=", "self", ".", "width", "*", "y", "+", "x", "self", ".", "back_r", "[", "i", "]", "=", "r", "self", ".", "back_g", "[", "i", "]", "=", "g", "self", ".", "back_b", "[", "i", "]", "=", "b" ]
Set the background color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red background color, from 0 to 255. g (int): Green background color, from 0 to 255. b (int): Blue background color, from 0 to 255.
[ "Set", "the", "background", "color", "of", "one", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L188-L201
9,268
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.set
def set( self, x: int, y: int, back_r: int, back_g: int, back_b: int, fore_r: int, fore_g: int, fore_b: int, char: str, ) -> None: """Set the background color, foreground color and character of one cell. Args: x (int): X position to change. y (int): Y position to change. back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. fore_r (int): Red foreground color, from 0 to 255. fore_g (int): Green foreground color, from 0 to 255. fore_b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object. """ i = self.width * y + x self.back_r[i] = back_r self.back_g[i] = back_g self.back_b[i] = back_b self.fore_r[i] = fore_r self.fore_g[i] = fore_g self.fore_b[i] = fore_b self.char[i] = ord(char)
python
def set( self, x: int, y: int, back_r: int, back_g: int, back_b: int, fore_r: int, fore_g: int, fore_b: int, char: str, ) -> None: """Set the background color, foreground color and character of one cell. Args: x (int): X position to change. y (int): Y position to change. back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. fore_r (int): Red foreground color, from 0 to 255. fore_g (int): Green foreground color, from 0 to 255. fore_b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object. """ i = self.width * y + x self.back_r[i] = back_r self.back_g[i] = back_g self.back_b[i] = back_b self.fore_r[i] = fore_r self.fore_g[i] = fore_g self.fore_b[i] = fore_b self.char[i] = ord(char)
[ "def", "set", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "back_r", ":", "int", ",", "back_g", ":", "int", ",", "back_b", ":", "int", ",", "fore_r", ":", "int", ",", "fore_g", ":", "int", ",", "fore_b", ":", "int", ",", "char", ":", "str", ",", ")", "->", "None", ":", "i", "=", "self", ".", "width", "*", "y", "+", "x", "self", ".", "back_r", "[", "i", "]", "=", "back_r", "self", ".", "back_g", "[", "i", "]", "=", "back_g", "self", ".", "back_b", "[", "i", "]", "=", "back_b", "self", ".", "fore_r", "[", "i", "]", "=", "fore_r", "self", ".", "fore_g", "[", "i", "]", "=", "fore_g", "self", ".", "fore_b", "[", "i", "]", "=", "fore_b", "self", ".", "char", "[", "i", "]", "=", "ord", "(", "char", ")" ]
Set the background color, foreground color and character of one cell. Args: x (int): X position to change. y (int): Y position to change. back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. fore_r (int): Red foreground color, from 0 to 255. fore_g (int): Green foreground color, from 0 to 255. fore_b (int): Blue foreground color, from 0 to 255. char (AnyStr): A single character str or bytes object.
[ "Set", "the", "background", "color", "foreground", "color", "and", "character", "of", "one", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L203-L235
9,269
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.blit
def blit( self, dest: tcod.console.Console, fill_fore: bool = True, fill_back: bool = True, ) -> None: """Use libtcod's "fill" functions to write the buffer to a console. Args: dest (Console): Console object to modify. fill_fore (bool): If True, fill the foreground color and characters. fill_back (bool): If True, fill the background color. """ if not dest: dest = tcod.console.Console._from_cdata(ffi.NULL) if dest.width != self.width or dest.height != self.height: raise ValueError( "ConsoleBuffer.blit: " "Destination console has an incorrect size." ) if fill_back: bg = dest.bg.ravel() bg[0::3] = self.back_r bg[1::3] = self.back_g bg[2::3] = self.back_b if fill_fore: fg = dest.fg.ravel() fg[0::3] = self.fore_r fg[1::3] = self.fore_g fg[2::3] = self.fore_b dest.ch.ravel()[:] = self.char
python
def blit( self, dest: tcod.console.Console, fill_fore: bool = True, fill_back: bool = True, ) -> None: """Use libtcod's "fill" functions to write the buffer to a console. Args: dest (Console): Console object to modify. fill_fore (bool): If True, fill the foreground color and characters. fill_back (bool): If True, fill the background color. """ if not dest: dest = tcod.console.Console._from_cdata(ffi.NULL) if dest.width != self.width or dest.height != self.height: raise ValueError( "ConsoleBuffer.blit: " "Destination console has an incorrect size." ) if fill_back: bg = dest.bg.ravel() bg[0::3] = self.back_r bg[1::3] = self.back_g bg[2::3] = self.back_b if fill_fore: fg = dest.fg.ravel() fg[0::3] = self.fore_r fg[1::3] = self.fore_g fg[2::3] = self.fore_b dest.ch.ravel()[:] = self.char
[ "def", "blit", "(", "self", ",", "dest", ":", "tcod", ".", "console", ".", "Console", ",", "fill_fore", ":", "bool", "=", "True", ",", "fill_back", ":", "bool", "=", "True", ",", ")", "->", "None", ":", "if", "not", "dest", ":", "dest", "=", "tcod", ".", "console", ".", "Console", ".", "_from_cdata", "(", "ffi", ".", "NULL", ")", "if", "dest", ".", "width", "!=", "self", ".", "width", "or", "dest", ".", "height", "!=", "self", ".", "height", ":", "raise", "ValueError", "(", "\"ConsoleBuffer.blit: \"", "\"Destination console has an incorrect size.\"", ")", "if", "fill_back", ":", "bg", "=", "dest", ".", "bg", ".", "ravel", "(", ")", "bg", "[", "0", ":", ":", "3", "]", "=", "self", ".", "back_r", "bg", "[", "1", ":", ":", "3", "]", "=", "self", ".", "back_g", "bg", "[", "2", ":", ":", "3", "]", "=", "self", ".", "back_b", "if", "fill_fore", ":", "fg", "=", "dest", ".", "fg", ".", "ravel", "(", ")", "fg", "[", "0", ":", ":", "3", "]", "=", "self", ".", "fore_r", "fg", "[", "1", ":", ":", "3", "]", "=", "self", ".", "fore_g", "fg", "[", "2", ":", ":", "3", "]", "=", "self", ".", "fore_b", "dest", ".", "ch", ".", "ravel", "(", ")", "[", ":", "]", "=", "self", ".", "char" ]
Use libtcod's "fill" functions to write the buffer to a console. Args: dest (Console): Console object to modify. fill_fore (bool): If True, fill the foreground color and characters. fill_back (bool): If True, fill the background color.
[ "Use", "libtcod", "s", "fill", "functions", "to", "write", "the", "buffer", "to", "a", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L237-L271
9,270
libtcod/python-tcod
tcod/image.py
Image.clear
def clear(self, color: Tuple[int, int, int]) -> None: """Fill this entire Image with color. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_image_clear(self.image_c, color)
python
def clear(self, color: Tuple[int, int, int]) -> None: """Fill this entire Image with color. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_image_clear(self.image_c, color)
[ "def", "clear", "(", "self", ",", "color", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_image_clear", "(", "self", ".", "image_c", ",", "color", ")" ]
Fill this entire Image with color. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance.
[ "Fill", "this", "entire", "Image", "with", "color", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L59-L66
9,271
libtcod/python-tcod
tcod/image.py
Image.scale
def scale(self, width: int, height: int) -> None: """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. """ lib.TCOD_image_scale(self.image_c, width, height) self.width, self.height = width, height
python
def scale(self, width: int, height: int) -> None: """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. """ lib.TCOD_image_scale(self.image_c, width, height) self.width, self.height = width, height
[ "def", "scale", "(", "self", ",", "width", ":", "int", ",", "height", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_image_scale", "(", "self", ".", "image_c", ",", "width", ",", "height", ")", "self", ".", "width", ",", "self", ".", "height", "=", "width", ",", "height" ]
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.
[ "Scale", "this", "Image", "to", "the", "new", "width", "and", "height", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L88-L96
9,272
libtcod/python-tcod
tcod/image.py
Image.set_key_color
def set_key_color(self, color: Tuple[int, int, int]) -> None: """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. """ lib.TCOD_image_set_key_color(self.image_c, color)
python
def set_key_color(self, color: Tuple[int, int, int]) -> None: """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. """ lib.TCOD_image_set_key_color(self.image_c, color)
[ "def", "set_key_color", "(", "self", ",", "color", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_image_set_key_color", "(", "self", ".", "image_c", ",", "color", ")" ]
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.
[ "Set", "a", "color", "to", "be", "transparent", "during", "blitting", "functions", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L98-L105
9,273
libtcod/python-tcod
tcod/image.py
Image.get_alpha
def get_alpha(self, x: int, y: int) -> int: """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. """ return lib.TCOD_image_get_alpha(self.image_c, x, y)
python
def get_alpha(self, x: int, y: int) -> int: """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. """ return lib.TCOD_image_get_alpha(self.image_c, x, y)
[ "def", "get_alpha", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "int", ":", "return", "lib", ".", "TCOD_image_get_alpha", "(", "self", ".", "image_c", ",", "x", ",", "y", ")" ]
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.
[ "Get", "the", "Image", "alpha", "of", "the", "pixel", "at", "x", "y", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L107-L118
9,274
libtcod/python-tcod
tcod/image.py
Image.get_pixel
def get_pixel(self, x: int, y: int) -> Tuple[int, int, int]: """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. """ color = lib.TCOD_image_get_pixel(self.image_c, x, y) return color.r, color.g, color.b
python
def get_pixel(self, x: int, y: int) -> Tuple[int, int, int]: """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. """ color = lib.TCOD_image_get_pixel(self.image_c, x, y) return color.r, color.g, color.b
[ "def", "get_pixel", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Tuple", "[", "int", ",", "int", ",", "int", "]", ":", "color", "=", "lib", ".", "TCOD_image_get_pixel", "(", "self", ".", "image_c", ",", "x", ",", "y", ")", "return", "color", ".", "r", ",", "color", ".", "g", ",", "color", ".", "b" ]
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.
[ "Get", "the", "color", "of", "a", "pixel", "in", "this", "Image", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L145-L158
9,275
libtcod/python-tcod
tcod/image.py
Image.get_mipmap_pixel
def get_mipmap_pixel( self, left: float, top: float, right: float, bottom: float ) -> Tuple[int, int, int]: """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. """ color = lib.TCOD_image_get_mipmap_pixel( self.image_c, left, top, right, bottom ) return (color.r, color.g, color.b)
python
def get_mipmap_pixel( self, left: float, top: float, right: float, bottom: float ) -> Tuple[int, int, int]: """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. """ color = lib.TCOD_image_get_mipmap_pixel( self.image_c, left, top, right, bottom ) return (color.r, color.g, color.b)
[ "def", "get_mipmap_pixel", "(", "self", ",", "left", ":", "float", ",", "top", ":", "float", ",", "right", ":", "float", ",", "bottom", ":", "float", ")", "->", "Tuple", "[", "int", ",", "int", ",", "int", "]", ":", "color", "=", "lib", ".", "TCOD_image_get_mipmap_pixel", "(", "self", ".", "image_c", ",", "left", ",", "top", ",", "right", ",", "bottom", ")", "return", "(", "color", ".", "r", ",", "color", ".", "g", ",", "color", ".", "b", ")" ]
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.
[ "Get", "the", "average", "color", "of", "a", "rectangle", "in", "this", "Image", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L160-L183
9,276
libtcod/python-tcod
tcod/image.py
Image.put_pixel
def put_pixel(self, x: int, y: int, color: Tuple[int, int, int]) -> None: """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. """ lib.TCOD_image_put_pixel(self.image_c, x, y, color)
python
def put_pixel(self, x: int, y: int, color: Tuple[int, int, int]) -> None: """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. """ lib.TCOD_image_put_pixel(self.image_c, x, y, color)
[ "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", ")" ]
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.
[ "Change", "a", "pixel", "on", "this", "Image", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L185-L194
9,277
libtcod/python-tcod
tcod/image.py
Image.blit
def blit( self, console: tcod.console.Console, x: float, y: float, bg_blend: int, scale_x: float, scale_y: float, angle: float, ) -> None: """Blit onto a Console using scaling and rotation. Args: console (Console): Blit destination Console. x (float): Console X position for the center of the Image blit. y (float): Console Y position for the center of the Image blit. The Image blit is centered on this position. bg_blend (int): Background blending mode to use. scale_x (float): Scaling along Image x axis. Set to 1 for no scaling. Must be over 0. scale_y (float): Scaling along Image y axis. Set to 1 for no scaling. Must be over 0. angle (float): Rotation angle in radians. (Clockwise?) """ lib.TCOD_image_blit( self.image_c, _console(console), x, y, bg_blend, scale_x, scale_y, angle, )
python
def blit( self, console: tcod.console.Console, x: float, y: float, bg_blend: int, scale_x: float, scale_y: float, angle: float, ) -> None: """Blit onto a Console using scaling and rotation. Args: console (Console): Blit destination Console. x (float): Console X position for the center of the Image blit. y (float): Console Y position for the center of the Image blit. The Image blit is centered on this position. bg_blend (int): Background blending mode to use. scale_x (float): Scaling along Image x axis. Set to 1 for no scaling. Must be over 0. scale_y (float): Scaling along Image y axis. Set to 1 for no scaling. Must be over 0. angle (float): Rotation angle in radians. (Clockwise?) """ lib.TCOD_image_blit( self.image_c, _console(console), x, y, bg_blend, scale_x, scale_y, angle, )
[ "def", "blit", "(", "self", ",", "console", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "float", ",", "y", ":", "float", ",", "bg_blend", ":", "int", ",", "scale_x", ":", "float", ",", "scale_y", ":", "float", ",", "angle", ":", "float", ",", ")", "->", "None", ":", "lib", ".", "TCOD_image_blit", "(", "self", ".", "image_c", ",", "_console", "(", "console", ")", ",", "x", ",", "y", ",", "bg_blend", ",", "scale_x", ",", "scale_y", ",", "angle", ",", ")" ]
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?)
[ "Blit", "onto", "a", "Console", "using", "scaling", "and", "rotation", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L196-L229
9,278
libtcod/python-tcod
tcod/image.py
Image.blit_rect
def blit_rect( self, console: tcod.console.Console, x: int, y: int, width: int, height: int, bg_blend: int, ) -> None: """Blit onto a Console without scaling or rotation. Args: console (Console): Blit destination Console. x (int): Console tile X position starting from the left at 0. y (int): Console tile Y position starting from the top at 0. width (int): Use -1 for Image width. height (int): Use -1 for Image height. bg_blend (int): Background blending mode to use. """ lib.TCOD_image_blit_rect( self.image_c, _console(console), x, y, width, height, bg_blend )
python
def blit_rect( self, console: tcod.console.Console, x: int, y: int, width: int, height: int, bg_blend: int, ) -> None: """Blit onto a Console without scaling or rotation. Args: console (Console): Blit destination Console. x (int): Console tile X position starting from the left at 0. y (int): Console tile Y position starting from the top at 0. width (int): Use -1 for Image width. height (int): Use -1 for Image height. bg_blend (int): Background blending mode to use. """ lib.TCOD_image_blit_rect( self.image_c, _console(console), x, y, width, height, bg_blend )
[ "def", "blit_rect", "(", "self", ",", "console", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "bg_blend", ":", "int", ",", ")", "->", "None", ":", "lib", ".", "TCOD_image_blit_rect", "(", "self", ".", "image_c", ",", "_console", "(", "console", ")", ",", "x", ",", "y", ",", "width", ",", "height", ",", "bg_blend", ")" ]
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.
[ "Blit", "onto", "a", "Console", "without", "scaling", "or", "rotation", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L231-L252
9,279
libtcod/python-tcod
tcod/image.py
Image.blit_2x
def blit_2x( self, console: tcod.console.Console, dest_x: int, dest_y: int, img_x: int = 0, img_y: int = 0, img_width: int = -1, img_height: int = -1, ) -> None: """Blit onto a Console with double resolution. Args: console (Console): Blit destination Console. dest_x (int): Console tile X position starting from the left at 0. dest_y (int): Console tile Y position starting from the top at 0. img_x (int): Left corner pixel of the Image to blit img_y (int): Top corner pixel of the Image to blit img_width (int): Width of the Image to blit. Use -1 for the full Image width. img_height (int): Height of the Image to blit. Use -1 for the full Image height. """ lib.TCOD_image_blit_2x( self.image_c, _console(console), dest_x, dest_y, img_x, img_y, img_width, img_height, )
python
def blit_2x( self, console: tcod.console.Console, dest_x: int, dest_y: int, img_x: int = 0, img_y: int = 0, img_width: int = -1, img_height: int = -1, ) -> None: """Blit onto a Console with double resolution. Args: console (Console): Blit destination Console. dest_x (int): Console tile X position starting from the left at 0. dest_y (int): Console tile Y position starting from the top at 0. img_x (int): Left corner pixel of the Image to blit img_y (int): Top corner pixel of the Image to blit img_width (int): Width of the Image to blit. Use -1 for the full Image width. img_height (int): Height of the Image to blit. Use -1 for the full Image height. """ lib.TCOD_image_blit_2x( self.image_c, _console(console), dest_x, dest_y, img_x, img_y, img_width, img_height, )
[ "def", "blit_2x", "(", "self", ",", "console", ":", "tcod", ".", "console", ".", "Console", ",", "dest_x", ":", "int", ",", "dest_y", ":", "int", ",", "img_x", ":", "int", "=", "0", ",", "img_y", ":", "int", "=", "0", ",", "img_width", ":", "int", "=", "-", "1", ",", "img_height", ":", "int", "=", "-", "1", ",", ")", "->", "None", ":", "lib", ".", "TCOD_image_blit_2x", "(", "self", ".", "image_c", ",", "_console", "(", "console", ")", ",", "dest_x", ",", "dest_y", ",", "img_x", ",", "img_y", ",", "img_width", ",", "img_height", ",", ")" ]
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.
[ "Blit", "onto", "a", "Console", "with", "double", "resolution", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L254-L286
9,280
libtcod/python-tcod
tcod/image.py
Image.save_as
def save_as(self, filename: str) -> None: """Save the Image to a 32-bit .bmp or .png file. Args: filename (Text): File path to same this Image. """ lib.TCOD_image_save(self.image_c, filename.encode("utf-8"))
python
def save_as(self, filename: str) -> None: """Save the Image to a 32-bit .bmp or .png file. Args: filename (Text): File path to same this Image. """ lib.TCOD_image_save(self.image_c, filename.encode("utf-8"))
[ "def", "save_as", "(", "self", ",", "filename", ":", "str", ")", "->", "None", ":", "lib", ".", "TCOD_image_save", "(", "self", ".", "image_c", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")" ]
Save the Image to a 32-bit .bmp or .png file. Args: filename (Text): File path to same this Image.
[ "Save", "the", "Image", "to", "a", "32", "-", "bit", ".", "bmp", "or", ".", "png", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L288-L294
9,281
libtcod/python-tcod
examples/sdlevent.py
main
def main(): """Example program for tcod.event""" WIDTH, HEIGHT = 120, 60 TITLE = None with tcod.console_init_root(WIDTH, HEIGHT, TITLE, order="F", renderer=tcod.RENDERER_SDL) as console: tcod.sys_set_fps(24) while True: tcod.console_flush() for event in tcod.event.wait(): print(event) if event.type == "QUIT": raise SystemExit() elif event.type == "MOUSEMOTION": console.ch[:, -1] = 0 console.print_(0, HEIGHT - 1, str(event)) else: console.blit(console, 0, 0, 0, 1, WIDTH, HEIGHT - 2) console.ch[:, -3] = 0 console.print_(0, HEIGHT - 3, str(event))
python
def main(): """Example program for tcod.event""" WIDTH, HEIGHT = 120, 60 TITLE = None with tcod.console_init_root(WIDTH, HEIGHT, TITLE, order="F", renderer=tcod.RENDERER_SDL) as console: tcod.sys_set_fps(24) while True: tcod.console_flush() for event in tcod.event.wait(): print(event) if event.type == "QUIT": raise SystemExit() elif event.type == "MOUSEMOTION": console.ch[:, -1] = 0 console.print_(0, HEIGHT - 1, str(event)) else: console.blit(console, 0, 0, 0, 1, WIDTH, HEIGHT - 2) console.ch[:, -3] = 0 console.print_(0, HEIGHT - 3, str(event))
[ "def", "main", "(", ")", ":", "WIDTH", ",", "HEIGHT", "=", "120", ",", "60", "TITLE", "=", "None", "with", "tcod", ".", "console_init_root", "(", "WIDTH", ",", "HEIGHT", ",", "TITLE", ",", "order", "=", "\"F\"", ",", "renderer", "=", "tcod", ".", "RENDERER_SDL", ")", "as", "console", ":", "tcod", ".", "sys_set_fps", "(", "24", ")", "while", "True", ":", "tcod", ".", "console_flush", "(", ")", "for", "event", "in", "tcod", ".", "event", ".", "wait", "(", ")", ":", "print", "(", "event", ")", "if", "event", ".", "type", "==", "\"QUIT\"", ":", "raise", "SystemExit", "(", ")", "elif", "event", ".", "type", "==", "\"MOUSEMOTION\"", ":", "console", ".", "ch", "[", ":", ",", "-", "1", "]", "=", "0", "console", ".", "print_", "(", "0", ",", "HEIGHT", "-", "1", ",", "str", "(", "event", ")", ")", "else", ":", "console", ".", "blit", "(", "console", ",", "0", ",", "0", ",", "0", ",", "1", ",", "WIDTH", ",", "HEIGHT", "-", "2", ")", "console", ".", "ch", "[", ":", ",", "-", "3", "]", "=", "0", "console", ".", "print_", "(", "0", ",", "HEIGHT", "-", "3", ",", "str", "(", "event", ")", ")" ]
Example program for tcod.event
[ "Example", "program", "for", "tcod", ".", "event" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/examples/sdlevent.py#L7-L27
9,282
libtcod/python-tcod
scripts/tag_release.py
parse_changelog
def parse_changelog(args: Any) -> Tuple[str, str]: """Return an updated changelog and and the list of changes.""" with open("CHANGELOG.rst", "r") as file: match = re.match( pattern=r"(.*?Unreleased\n---+\n)(.+?)(\n*[^\n]+\n---+\n.*)", string=file.read(), flags=re.DOTALL, ) assert match header, changes, tail = match.groups() tag = "%s - %s" % (args.tag, datetime.date.today().isoformat()) tagged = "\n%s\n%s\n%s" % (tag, "-" * len(tag), changes) if args.verbose: print(tagged) return "".join((header, tagged, tail)), changes
python
def parse_changelog(args: Any) -> Tuple[str, str]: """Return an updated changelog and and the list of changes.""" with open("CHANGELOG.rst", "r") as file: match = re.match( pattern=r"(.*?Unreleased\n---+\n)(.+?)(\n*[^\n]+\n---+\n.*)", string=file.read(), flags=re.DOTALL, ) assert match header, changes, tail = match.groups() tag = "%s - %s" % (args.tag, datetime.date.today().isoformat()) tagged = "\n%s\n%s\n%s" % (tag, "-" * len(tag), changes) if args.verbose: print(tagged) return "".join((header, tagged, tail)), changes
[ "def", "parse_changelog", "(", "args", ":", "Any", ")", "->", "Tuple", "[", "str", ",", "str", "]", ":", "with", "open", "(", "\"CHANGELOG.rst\"", ",", "\"r\"", ")", "as", "file", ":", "match", "=", "re", ".", "match", "(", "pattern", "=", "r\"(.*?Unreleased\\n---+\\n)(.+?)(\\n*[^\\n]+\\n---+\\n.*)\"", ",", "string", "=", "file", ".", "read", "(", ")", ",", "flags", "=", "re", ".", "DOTALL", ",", ")", "assert", "match", "header", ",", "changes", ",", "tail", "=", "match", ".", "groups", "(", ")", "tag", "=", "\"%s - %s\"", "%", "(", "args", ".", "tag", ",", "datetime", ".", "date", ".", "today", "(", ")", ".", "isoformat", "(", ")", ")", "tagged", "=", "\"\\n%s\\n%s\\n%s\"", "%", "(", "tag", ",", "\"-\"", "*", "len", "(", "tag", ")", ",", "changes", ")", "if", "args", ".", "verbose", ":", "print", "(", "tagged", ")", "return", "\"\"", ".", "join", "(", "(", "header", ",", "tagged", ",", "tail", ")", ")", ",", "changes" ]
Return an updated changelog and and the list of changes.
[ "Return", "an", "updated", "changelog", "and", "and", "the", "list", "of", "changes", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/scripts/tag_release.py#L29-L45
9,283
libtcod/python-tcod
tcod/bsp.py
BSP.split_once
def split_once(self, horizontal: bool, position: int) -> None: """Split this partition into 2 sub-partitions. Args: horizontal (bool): position (int): """ cdata = self._as_cdata() lib.TCOD_bsp_split_once(cdata, horizontal, position) self._unpack_bsp_tree(cdata)
python
def split_once(self, horizontal: bool, position: int) -> None: """Split this partition into 2 sub-partitions. Args: horizontal (bool): position (int): """ cdata = self._as_cdata() lib.TCOD_bsp_split_once(cdata, horizontal, position) self._unpack_bsp_tree(cdata)
[ "def", "split_once", "(", "self", ",", "horizontal", ":", "bool", ",", "position", ":", "int", ")", "->", "None", ":", "cdata", "=", "self", ".", "_as_cdata", "(", ")", "lib", ".", "TCOD_bsp_split_once", "(", "cdata", ",", "horizontal", ",", "position", ")", "self", ".", "_unpack_bsp_tree", "(", "cdata", ")" ]
Split this partition into 2 sub-partitions. Args: horizontal (bool): position (int):
[ "Split", "this", "partition", "into", "2", "sub", "-", "partitions", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L131-L140
9,284
libtcod/python-tcod
tcod/bsp.py
BSP.split_recursive
def split_recursive( self, depth: int, min_width: int, min_height: int, max_horizontal_ratio: float, max_vertical_ratio: float, seed: Optional[tcod.random.Random] = None, ) -> None: """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. """ cdata = self._as_cdata() lib.TCOD_bsp_split_recursive( cdata, seed or ffi.NULL, depth, min_width, min_height, max_horizontal_ratio, max_vertical_ratio, ) self._unpack_bsp_tree(cdata)
python
def split_recursive( self, depth: int, min_width: int, min_height: int, max_horizontal_ratio: float, max_vertical_ratio: float, seed: Optional[tcod.random.Random] = None, ) -> None: """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. """ cdata = self._as_cdata() lib.TCOD_bsp_split_recursive( cdata, seed or ffi.NULL, depth, min_width, min_height, max_horizontal_ratio, max_vertical_ratio, ) self._unpack_bsp_tree(cdata)
[ "def", "split_recursive", "(", "self", ",", "depth", ":", "int", ",", "min_width", ":", "int", ",", "min_height", ":", "int", ",", "max_horizontal_ratio", ":", "float", ",", "max_vertical_ratio", ":", "float", ",", "seed", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", "=", "None", ",", ")", "->", "None", ":", "cdata", "=", "self", ".", "_as_cdata", "(", ")", "lib", ".", "TCOD_bsp_split_recursive", "(", "cdata", ",", "seed", "or", "ffi", ".", "NULL", ",", "depth", ",", "min_width", ",", "min_height", ",", "max_horizontal_ratio", ",", "max_vertical_ratio", ",", ")", "self", ".", "_unpack_bsp_tree", "(", "cdata", ")" ]
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.
[ "Divide", "this", "partition", "recursively", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L142-L174
9,285
libtcod/python-tcod
tcod/bsp.py
BSP.in_order
def in_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in order. .. versionadded:: 8.3 """ if self.children: yield from self.children[0].in_order() yield self yield from self.children[1].in_order() else: yield self
python
def in_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in order. .. versionadded:: 8.3 """ if self.children: yield from self.children[0].in_order() yield self yield from self.children[1].in_order() else: yield self
[ "def", "in_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "if", "self", ".", "children", ":", "yield", "from", "self", ".", "children", "[", "0", "]", ".", "in_order", "(", ")", "yield", "self", "yield", "from", "self", ".", "children", "[", "1", "]", ".", "in_order", "(", ")", "else", ":", "yield", "self" ]
Iterate over this BSP's hierarchy in order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "order", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L194-L204
9,286
libtcod/python-tcod
tcod/bsp.py
BSP.level_order
def level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3 """ next = [self] # type: List['BSP'] while next: level = next # type: List['BSP'] next = [] yield from level for node in level: next.extend(node.children)
python
def level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3 """ next = [self] # type: List['BSP'] while next: level = next # type: List['BSP'] next = [] yield from level for node in level: next.extend(node.children)
[ "def", "level_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "next", "=", "[", "self", "]", "# type: List['BSP']", "while", "next", ":", "level", "=", "next", "# type: List['BSP']", "next", "=", "[", "]", "yield", "from", "level", "for", "node", "in", "level", ":", "next", ".", "extend", "(", "node", ".", "children", ")" ]
Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "level", "order", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L215-L226
9,287
libtcod/python-tcod
tcod/bsp.py
BSP.inverted_level_order
def inverted_level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in inverse level order. .. versionadded:: 8.3 """ levels = [] # type: List[List['BSP']] next = [self] # type: List['BSP'] while next: levels.append(next) level = next # type: List['BSP'] next = [] for node in level: next.extend(node.children) while levels: yield from levels.pop()
python
def inverted_level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in inverse level order. .. versionadded:: 8.3 """ levels = [] # type: List[List['BSP']] next = [self] # type: List['BSP'] while next: levels.append(next) level = next # type: List['BSP'] next = [] for node in level: next.extend(node.children) while levels: yield from levels.pop()
[ "def", "inverted_level_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "levels", "=", "[", "]", "# type: List[List['BSP']]", "next", "=", "[", "self", "]", "# type: List['BSP']", "while", "next", ":", "levels", ".", "append", "(", "next", ")", "level", "=", "next", "# type: List['BSP']", "next", "=", "[", "]", "for", "node", "in", "level", ":", "next", ".", "extend", "(", "node", ".", "children", ")", "while", "levels", ":", "yield", "from", "levels", ".", "pop", "(", ")" ]
Iterate over this BSP's hierarchy in inverse level order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "inverse", "level", "order", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L228-L242
9,288
libtcod/python-tcod
tcod/bsp.py
BSP.contains
def contains(self, x: int, y: int) -> bool: """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. """ return ( self.x <= x < self.x + self.width and self.y <= y < self.y + self.height )
python
def contains(self, x: int, y: int) -> bool: """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. """ return ( self.x <= x < self.x + self.width and self.y <= y < self.y + self.height )
[ "def", "contains", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "bool", ":", "return", "(", "self", ".", "x", "<=", "x", "<", "self", ".", "x", "+", "self", ".", "width", "and", "self", ".", "y", "<=", "y", "<", "self", ".", "y", "+", "self", ".", "height", ")" ]
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.
[ "Returns", "True", "if", "this", "node", "contains", "these", "coordinates", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L244-L258
9,289
libtcod/python-tcod
tcod/bsp.py
BSP.find_node
def find_node(self, x: int, y: int) -> Optional["BSP"]: """Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None. """ if not self.contains(x, y): return None for child in self.children: found = child.find_node(x, y) # type: Optional["BSP"] if found: return found return self
python
def find_node(self, x: int, y: int) -> Optional["BSP"]: """Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None. """ if not self.contains(x, y): return None for child in self.children: found = child.find_node(x, y) # type: Optional["BSP"] if found: return found return self
[ "def", "find_node", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Optional", "[", "\"BSP\"", "]", ":", "if", "not", "self", ".", "contains", "(", "x", ",", "y", ")", ":", "return", "None", "for", "child", "in", "self", ".", "children", ":", "found", "=", "child", ".", "find_node", "(", "x", ",", "y", ")", "# type: Optional[\"BSP\"]", "if", "found", ":", "return", "found", "return", "self" ]
Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None.
[ "Return", "the", "deepest", "node", "which", "contains", "these", "coordinates", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L260-L272
9,290
libtcod/python-tcod
tdl/style.py
backport
def backport(func): """ Backport a function name into an old style for compatibility. The docstring is updated to reflect that the new function returned is deprecated and that the other function is preferred. A DeprecationWarning is also raised for using this function. If the script is run with an optimization flag then the real function will be returned without being wrapped. """ if not __debug__: return func @_functools.wraps(func) def deprecated_function(*args, **kargs): _warnings.warn('This function name is deprecated', DeprecationWarning, 2) return func(*args, **kargs) deprecated_function.__doc__ = None return deprecated_function
python
def backport(func): """ Backport a function name into an old style for compatibility. The docstring is updated to reflect that the new function returned is deprecated and that the other function is preferred. A DeprecationWarning is also raised for using this function. If the script is run with an optimization flag then the real function will be returned without being wrapped. """ if not __debug__: return func @_functools.wraps(func) def deprecated_function(*args, **kargs): _warnings.warn('This function name is deprecated', DeprecationWarning, 2) return func(*args, **kargs) deprecated_function.__doc__ = None return deprecated_function
[ "def", "backport", "(", "func", ")", ":", "if", "not", "__debug__", ":", "return", "func", "@", "_functools", ".", "wraps", "(", "func", ")", "def", "deprecated_function", "(", "*", "args", ",", "*", "*", "kargs", ")", ":", "_warnings", ".", "warn", "(", "'This function name is deprecated'", ",", "DeprecationWarning", ",", "2", ")", "return", "func", "(", "*", "args", ",", "*", "*", "kargs", ")", "deprecated_function", ".", "__doc__", "=", "None", "return", "deprecated_function" ]
Backport a function name into an old style for compatibility. The docstring is updated to reflect that the new function returned is deprecated and that the other function is preferred. A DeprecationWarning is also raised for using this function. If the script is run with an optimization flag then the real function will be returned without being wrapped.
[ "Backport", "a", "function", "name", "into", "an", "old", "style", "for", "compatibility", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/style.py#L9-L29
9,291
libtcod/python-tcod
tdl/map.py
_get_fov_type
def _get_fov_type(fov): "Return a FOV from a string" oldFOV = fov fov = str(fov).upper() if fov in _FOVTYPES: return _FOVTYPES[fov] if fov[:10] == 'PERMISSIVE' and fov[10].isdigit() and fov[10] != '9': return 4 + int(fov[10]) raise _tdl.TDLError('No such fov option as %s' % oldFOV)
python
def _get_fov_type(fov): "Return a FOV from a string" oldFOV = fov fov = str(fov).upper() if fov in _FOVTYPES: return _FOVTYPES[fov] if fov[:10] == 'PERMISSIVE' and fov[10].isdigit() and fov[10] != '9': return 4 + int(fov[10]) raise _tdl.TDLError('No such fov option as %s' % oldFOV)
[ "def", "_get_fov_type", "(", "fov", ")", ":", "oldFOV", "=", "fov", "fov", "=", "str", "(", "fov", ")", ".", "upper", "(", ")", "if", "fov", "in", "_FOVTYPES", ":", "return", "_FOVTYPES", "[", "fov", "]", "if", "fov", "[", ":", "10", "]", "==", "'PERMISSIVE'", "and", "fov", "[", "10", "]", ".", "isdigit", "(", ")", "and", "fov", "[", "10", "]", "!=", "'9'", ":", "return", "4", "+", "int", "(", "fov", "[", "10", "]", ")", "raise", "_tdl", ".", "TDLError", "(", "'No such fov option as %s'", "%", "oldFOV", ")" ]
Return a FOV from a string
[ "Return", "a", "FOV", "from", "a", "string" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L29-L37
9,292
libtcod/python-tcod
tdl/map.py
quick_fov
def quick_fov(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sphere=True): """All field-of-view functionality in one call. Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass through the tile or False for light-blocking tiles and for indexes that are out of bounds of the dungeon. This function is 'quick' as in no hassle but can quickly become a very slow function call if a large radius is used or the callback provided itself isn't optimized. Always check if the index is in bounds both in the callback and in the returned values. These values can go into the negatives as well. Args: x (int): x center of the field-of-view y (int): y center of the field-of-view callback (Callable[[int, int], bool]): This should be a function that takes two positional arguments x,y and returns True if the tile at that position is transparent or False if the tile blocks light or is out of bounds. fov (Text): The type of field-of-view to be used. Available types are: 'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8' radius (float) Radius of the field-of-view. When sphere is True a floating point can be used to fine-tune the range. Otherwise the radius is just rounded up. Be careful as a large radius has an exponential affect on how long this function takes. lightWalls (bool): Include or exclude wall tiles in the field-of-view. sphere (bool): True for a spherical field-of-view. False for a square one. Returns: Set[Tuple[int, int]]: A set of (x, y) points that are within the field-of-view. """ trueRadius = radius radius = int(_math.ceil(radius)) mapSize = radius * 2 + 1 fov = _get_fov_type(fov) setProp = _lib.TCOD_map_set_properties # make local inFOV = _lib.TCOD_map_is_in_fov tcodMap = _lib.TCOD_map_new(mapSize, mapSize) try: # pass no.1, write callback data to the tcodMap for x_, y_ in _itertools.product(range(mapSize), range(mapSize)): pos = (x_ + x - radius, y_ + y - radius) transparent = bool(callback(*pos)) setProp(tcodMap, x_, y_, transparent, False) # pass no.2, compute fov and build a list of points _lib.TCOD_map_compute_fov(tcodMap, radius, radius, radius, lightWalls, fov) touched = set() # points touched by field of view for x_, y_ in _itertools.product(range(mapSize), range(mapSize)): if sphere and _math.hypot(x_ - radius, y_ - radius) > trueRadius: continue if inFOV(tcodMap, x_, y_): touched.add((x_ + x - radius, y_ + y - radius)) finally: _lib.TCOD_map_delete(tcodMap) return touched
python
def quick_fov(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sphere=True): """All field-of-view functionality in one call. Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass through the tile or False for light-blocking tiles and for indexes that are out of bounds of the dungeon. This function is 'quick' as in no hassle but can quickly become a very slow function call if a large radius is used or the callback provided itself isn't optimized. Always check if the index is in bounds both in the callback and in the returned values. These values can go into the negatives as well. Args: x (int): x center of the field-of-view y (int): y center of the field-of-view callback (Callable[[int, int], bool]): This should be a function that takes two positional arguments x,y and returns True if the tile at that position is transparent or False if the tile blocks light or is out of bounds. fov (Text): The type of field-of-view to be used. Available types are: 'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8' radius (float) Radius of the field-of-view. When sphere is True a floating point can be used to fine-tune the range. Otherwise the radius is just rounded up. Be careful as a large radius has an exponential affect on how long this function takes. lightWalls (bool): Include or exclude wall tiles in the field-of-view. sphere (bool): True for a spherical field-of-view. False for a square one. Returns: Set[Tuple[int, int]]: A set of (x, y) points that are within the field-of-view. """ trueRadius = radius radius = int(_math.ceil(radius)) mapSize = radius * 2 + 1 fov = _get_fov_type(fov) setProp = _lib.TCOD_map_set_properties # make local inFOV = _lib.TCOD_map_is_in_fov tcodMap = _lib.TCOD_map_new(mapSize, mapSize) try: # pass no.1, write callback data to the tcodMap for x_, y_ in _itertools.product(range(mapSize), range(mapSize)): pos = (x_ + x - radius, y_ + y - radius) transparent = bool(callback(*pos)) setProp(tcodMap, x_, y_, transparent, False) # pass no.2, compute fov and build a list of points _lib.TCOD_map_compute_fov(tcodMap, radius, radius, radius, lightWalls, fov) touched = set() # points touched by field of view for x_, y_ in _itertools.product(range(mapSize), range(mapSize)): if sphere and _math.hypot(x_ - radius, y_ - radius) > trueRadius: continue if inFOV(tcodMap, x_, y_): touched.add((x_ + x - radius, y_ + y - radius)) finally: _lib.TCOD_map_delete(tcodMap) return touched
[ "def", "quick_fov", "(", "x", ",", "y", ",", "callback", ",", "fov", "=", "'PERMISSIVE'", ",", "radius", "=", "7.5", ",", "lightWalls", "=", "True", ",", "sphere", "=", "True", ")", ":", "trueRadius", "=", "radius", "radius", "=", "int", "(", "_math", ".", "ceil", "(", "radius", ")", ")", "mapSize", "=", "radius", "*", "2", "+", "1", "fov", "=", "_get_fov_type", "(", "fov", ")", "setProp", "=", "_lib", ".", "TCOD_map_set_properties", "# make local", "inFOV", "=", "_lib", ".", "TCOD_map_is_in_fov", "tcodMap", "=", "_lib", ".", "TCOD_map_new", "(", "mapSize", ",", "mapSize", ")", "try", ":", "# pass no.1, write callback data to the tcodMap", "for", "x_", ",", "y_", "in", "_itertools", ".", "product", "(", "range", "(", "mapSize", ")", ",", "range", "(", "mapSize", ")", ")", ":", "pos", "=", "(", "x_", "+", "x", "-", "radius", ",", "y_", "+", "y", "-", "radius", ")", "transparent", "=", "bool", "(", "callback", "(", "*", "pos", ")", ")", "setProp", "(", "tcodMap", ",", "x_", ",", "y_", ",", "transparent", ",", "False", ")", "# pass no.2, compute fov and build a list of points", "_lib", ".", "TCOD_map_compute_fov", "(", "tcodMap", ",", "radius", ",", "radius", ",", "radius", ",", "lightWalls", ",", "fov", ")", "touched", "=", "set", "(", ")", "# points touched by field of view", "for", "x_", ",", "y_", "in", "_itertools", ".", "product", "(", "range", "(", "mapSize", ")", ",", "range", "(", "mapSize", ")", ")", ":", "if", "sphere", "and", "_math", ".", "hypot", "(", "x_", "-", "radius", ",", "y_", "-", "radius", ")", ">", "trueRadius", ":", "continue", "if", "inFOV", "(", "tcodMap", ",", "x_", ",", "y_", ")", ":", "touched", ".", "add", "(", "(", "x_", "+", "x", "-", "radius", ",", "y_", "+", "y", "-", "radius", ")", ")", "finally", ":", "_lib", ".", "TCOD_map_delete", "(", "tcodMap", ")", "return", "touched" ]
All field-of-view functionality in one call. Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass through the tile or False for light-blocking tiles and for indexes that are out of bounds of the dungeon. This function is 'quick' as in no hassle but can quickly become a very slow function call if a large radius is used or the callback provided itself isn't optimized. Always check if the index is in bounds both in the callback and in the returned values. These values can go into the negatives as well. Args: x (int): x center of the field-of-view y (int): y center of the field-of-view callback (Callable[[int, int], bool]): This should be a function that takes two positional arguments x,y and returns True if the tile at that position is transparent or False if the tile blocks light or is out of bounds. fov (Text): The type of field-of-view to be used. Available types are: 'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8' radius (float) Radius of the field-of-view. When sphere is True a floating point can be used to fine-tune the range. Otherwise the radius is just rounded up. Be careful as a large radius has an exponential affect on how long this function takes. lightWalls (bool): Include or exclude wall tiles in the field-of-view. sphere (bool): True for a spherical field-of-view. False for a square one. Returns: Set[Tuple[int, int]]: A set of (x, y) points that are within the field-of-view.
[ "All", "field", "-", "of", "-", "view", "functionality", "in", "one", "call", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L235-L306
9,293
libtcod/python-tcod
tdl/map.py
bresenham
def bresenham(x1, y1, x2, y2): """ Return a list of points in a bresenham line. Implementation hastily copied from RogueBasin. Returns: List[Tuple[int, int]]: A list of (x, y) points, including both the start and end-points. """ points = [] issteep = abs(y2-y1) > abs(x2-x1) if issteep: x1, y1 = y1, x1 x2, y2 = y2, x2 rev = False if x1 > x2: x1, x2 = x2, x1 y1, y2 = y2, y1 rev = True deltax = x2 - x1 deltay = abs(y2-y1) error = int(deltax / 2) y = y1 ystep = None if y1 < y2: ystep = 1 else: ystep = -1 for x in range(x1, x2 + 1): if issteep: points.append((y, x)) else: points.append((x, y)) error -= deltay if error < 0: y += ystep error += deltax # Reverse the list if the coordinates were reversed if rev: points.reverse() return points
python
def bresenham(x1, y1, x2, y2): """ Return a list of points in a bresenham line. Implementation hastily copied from RogueBasin. Returns: List[Tuple[int, int]]: A list of (x, y) points, including both the start and end-points. """ points = [] issteep = abs(y2-y1) > abs(x2-x1) if issteep: x1, y1 = y1, x1 x2, y2 = y2, x2 rev = False if x1 > x2: x1, x2 = x2, x1 y1, y2 = y2, y1 rev = True deltax = x2 - x1 deltay = abs(y2-y1) error = int(deltax / 2) y = y1 ystep = None if y1 < y2: ystep = 1 else: ystep = -1 for x in range(x1, x2 + 1): if issteep: points.append((y, x)) else: points.append((x, y)) error -= deltay if error < 0: y += ystep error += deltax # Reverse the list if the coordinates were reversed if rev: points.reverse() return points
[ "def", "bresenham", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "points", "=", "[", "]", "issteep", "=", "abs", "(", "y2", "-", "y1", ")", ">", "abs", "(", "x2", "-", "x1", ")", "if", "issteep", ":", "x1", ",", "y1", "=", "y1", ",", "x1", "x2", ",", "y2", "=", "y2", ",", "x2", "rev", "=", "False", "if", "x1", ">", "x2", ":", "x1", ",", "x2", "=", "x2", ",", "x1", "y1", ",", "y2", "=", "y2", ",", "y1", "rev", "=", "True", "deltax", "=", "x2", "-", "x1", "deltay", "=", "abs", "(", "y2", "-", "y1", ")", "error", "=", "int", "(", "deltax", "/", "2", ")", "y", "=", "y1", "ystep", "=", "None", "if", "y1", "<", "y2", ":", "ystep", "=", "1", "else", ":", "ystep", "=", "-", "1", "for", "x", "in", "range", "(", "x1", ",", "x2", "+", "1", ")", ":", "if", "issteep", ":", "points", ".", "append", "(", "(", "y", ",", "x", ")", ")", "else", ":", "points", ".", "append", "(", "(", "x", ",", "y", ")", ")", "error", "-=", "deltay", "if", "error", "<", "0", ":", "y", "+=", "ystep", "error", "+=", "deltax", "# Reverse the list if the coordinates were reversed", "if", "rev", ":", "points", ".", "reverse", "(", ")", "return", "points" ]
Return a list of points in a bresenham line. Implementation hastily copied from RogueBasin. Returns: List[Tuple[int, int]]: A list of (x, y) points, including both the start and end-points.
[ "Return", "a", "list", "of", "points", "in", "a", "bresenham", "line", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L308-L349
9,294
libtcod/python-tcod
tdl/map.py
Map.compute_fov
def compute_fov(self, x, y, fov='PERMISSIVE', radius=None, light_walls=True, sphere=True, cumulative=False): """Compute the field-of-view of this Map and return an iterator of the points touched. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. fov (Text): The type of field-of-view to be used. Available types are: 'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8' radius (Optional[int]): Maximum view distance from the point of view. A value of 0 will give an infinite distance. light_walls (bool): Light up walls, or only the floor. sphere (bool): If True the lit area will be round instead of square. cumulative (bool): If True the lit cells will accumulate instead of being cleared before the computation. Returns: Iterator[Tuple[int, int]]: An iterator of (x, y) points of tiles touched by the field-of-view. """ # refresh cdata if radius is None: # infinite radius radius = 0 if cumulative: fov_copy = self.fov.copy() lib.TCOD_map_compute_fov( self.map_c, x, y, radius, light_walls, _get_fov_type(fov)) if cumulative: self.fov[:] |= fov_copy return zip(*np.where(self.fov))
python
def compute_fov(self, x, y, fov='PERMISSIVE', radius=None, light_walls=True, sphere=True, cumulative=False): """Compute the field-of-view of this Map and return an iterator of the points touched. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. fov (Text): The type of field-of-view to be used. Available types are: 'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8' radius (Optional[int]): Maximum view distance from the point of view. A value of 0 will give an infinite distance. light_walls (bool): Light up walls, or only the floor. sphere (bool): If True the lit area will be round instead of square. cumulative (bool): If True the lit cells will accumulate instead of being cleared before the computation. Returns: Iterator[Tuple[int, int]]: An iterator of (x, y) points of tiles touched by the field-of-view. """ # refresh cdata if radius is None: # infinite radius radius = 0 if cumulative: fov_copy = self.fov.copy() lib.TCOD_map_compute_fov( self.map_c, x, y, radius, light_walls, _get_fov_type(fov)) if cumulative: self.fov[:] |= fov_copy return zip(*np.where(self.fov))
[ "def", "compute_fov", "(", "self", ",", "x", ",", "y", ",", "fov", "=", "'PERMISSIVE'", ",", "radius", "=", "None", ",", "light_walls", "=", "True", ",", "sphere", "=", "True", ",", "cumulative", "=", "False", ")", ":", "# refresh cdata", "if", "radius", "is", "None", ":", "# infinite radius", "radius", "=", "0", "if", "cumulative", ":", "fov_copy", "=", "self", ".", "fov", ".", "copy", "(", ")", "lib", ".", "TCOD_map_compute_fov", "(", "self", ".", "map_c", ",", "x", ",", "y", ",", "radius", ",", "light_walls", ",", "_get_fov_type", "(", "fov", ")", ")", "if", "cumulative", ":", "self", ".", "fov", "[", ":", "]", "|=", "fov_copy", "return", "zip", "(", "*", "np", ".", "where", "(", "self", ".", "fov", ")", ")" ]
Compute the field-of-view of this Map and return an iterator of the points touched. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. fov (Text): The type of field-of-view to be used. Available types are: 'BASIC', 'DIAMOND', 'SHADOW', 'RESTRICTIVE', 'PERMISSIVE', 'PERMISSIVE0', 'PERMISSIVE1', ..., 'PERMISSIVE8' radius (Optional[int]): Maximum view distance from the point of view. A value of 0 will give an infinite distance. light_walls (bool): Light up walls, or only the floor. sphere (bool): If True the lit area will be round instead of square. cumulative (bool): If True the lit cells will accumulate instead of being cleared before the computation. Returns: Iterator[Tuple[int, int]]: An iterator of (x, y) points of tiles touched by the field-of-view.
[ "Compute", "the", "field", "-", "of", "-", "view", "of", "this", "Map", "and", "return", "an", "iterator", "of", "the", "points", "touched", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L94-L130
9,295
libtcod/python-tcod
tdl/map.py
Map.compute_path
def compute_path(self, start_x, start_y, dest_x, dest_y, diagonal_cost=_math.sqrt(2)): """Get the shortest path between two points. Args: start_x (int): Starting x-position. start_y (int): Starting y-position. dest_x (int): Destination x-position. dest_y (int): Destination y-position. diagonal_cost (float): Multiplier for diagonal movement. Can be set to zero to disable diagonal movement entirely. Returns: List[Tuple[int, int]]: The shortest list of points to the destination position from the starting position. The start point is not included in this list. """ return tcod.path.AStar(self, diagonal_cost).get_path(start_x, start_y, dest_x, dest_y)
python
def compute_path(self, start_x, start_y, dest_x, dest_y, diagonal_cost=_math.sqrt(2)): """Get the shortest path between two points. Args: start_x (int): Starting x-position. start_y (int): Starting y-position. dest_x (int): Destination x-position. dest_y (int): Destination y-position. diagonal_cost (float): Multiplier for diagonal movement. Can be set to zero to disable diagonal movement entirely. Returns: List[Tuple[int, int]]: The shortest list of points to the destination position from the starting position. The start point is not included in this list. """ return tcod.path.AStar(self, diagonal_cost).get_path(start_x, start_y, dest_x, dest_y)
[ "def", "compute_path", "(", "self", ",", "start_x", ",", "start_y", ",", "dest_x", ",", "dest_y", ",", "diagonal_cost", "=", "_math", ".", "sqrt", "(", "2", ")", ")", ":", "return", "tcod", ".", "path", ".", "AStar", "(", "self", ",", "diagonal_cost", ")", ".", "get_path", "(", "start_x", ",", "start_y", ",", "dest_x", ",", "dest_y", ")" ]
Get the shortest path between two points. Args: start_x (int): Starting x-position. start_y (int): Starting y-position. dest_x (int): Destination x-position. dest_y (int): Destination y-position. diagonal_cost (float): Multiplier for diagonal movement. Can be set to zero to disable diagonal movement entirely. Returns: List[Tuple[int, int]]: The shortest list of points to the destination position from the starting position. The start point is not included in this list.
[ "Get", "the", "shortest", "path", "between", "two", "points", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L133-L153
9,296
libtcod/python-tcod
tdl/map.py
AStar.get_path
def get_path(self, origX, origY, destX, destY): """ Get the shortest path from origXY to destXY. Returns: List[Tuple[int, int]]: Returns a list walking the path from orig to dest. This excludes the starting point and includes the destination. If no path is found then an empty list is returned. """ return super(AStar, self).get_path(origX, origY, destX, destY)
python
def get_path(self, origX, origY, destX, destY): """ Get the shortest path from origXY to destXY. Returns: List[Tuple[int, int]]: Returns a list walking the path from orig to dest. This excludes the starting point and includes the destination. If no path is found then an empty list is returned. """ return super(AStar, self).get_path(origX, origY, destX, destY)
[ "def", "get_path", "(", "self", ",", "origX", ",", "origY", ",", "destX", ",", "destY", ")", ":", "return", "super", "(", "AStar", ",", "self", ")", ".", "get_path", "(", "origX", ",", "origY", ",", "destX", ",", "destY", ")" ]
Get the shortest path from origXY to destXY. Returns: List[Tuple[int, int]]: Returns a list walking the path from orig to dest. This excludes the starting point and includes the destination. If no path is found then an empty list is returned.
[ "Get", "the", "shortest", "path", "from", "origXY", "to", "destXY", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L220-L232
9,297
libtcod/python-tcod
setup.py
get_long_description
def get_long_description(): """Return this projects description.""" with open("README.rst", "r") as f: readme = f.read() with open("CHANGELOG.rst", "r") as f: changelog = f.read() changelog = changelog.replace("\nUnreleased\n------------------", "") return "\n".join([readme, changelog])
python
def get_long_description(): """Return this projects description.""" with open("README.rst", "r") as f: readme = f.read() with open("CHANGELOG.rst", "r") as f: changelog = f.read() changelog = changelog.replace("\nUnreleased\n------------------", "") return "\n".join([readme, changelog])
[ "def", "get_long_description", "(", ")", ":", "with", "open", "(", "\"README.rst\"", ",", "\"r\"", ")", "as", "f", ":", "readme", "=", "f", ".", "read", "(", ")", "with", "open", "(", "\"CHANGELOG.rst\"", ",", "\"r\"", ")", "as", "f", ":", "changelog", "=", "f", ".", "read", "(", ")", "changelog", "=", "changelog", ".", "replace", "(", "\"\\nUnreleased\\n------------------\"", ",", "\"\"", ")", "return", "\"\\n\"", ".", "join", "(", "[", "readme", ",", "changelog", "]", ")" ]
Return this projects description.
[ "Return", "this", "projects", "description", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/setup.py#L78-L85
9,298
libtcod/python-tcod
tcod/console.py
get_height_rect
def get_height_rect(width: int, string: str) -> int: """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 """ string_ = string.encode("utf-8") # type: bytes return int(lib.get_height_rect2(width, string_, len(string_)))
python
def get_height_rect(width: int, string: str) -> int: """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 """ string_ = string.encode("utf-8") # type: bytes return int(lib.get_height_rect2(width, string_, len(string_)))
[ "def", "get_height_rect", "(", "width", ":", "int", ",", "string", ":", "str", ")", "->", "int", ":", "string_", "=", "string", ".", "encode", "(", "\"utf-8\"", ")", "# type: bytes", "return", "int", "(", "lib", ".", "get_height_rect2", "(", "width", ",", "string_", ",", "len", "(", "string_", ")", ")", ")" ]
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
[ "Return", "the", "number", "of", "lines", "which", "would", "be", "printed", "from", "these", "parameters", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L1084-L1094
9,299
libtcod/python-tcod
tcod/console.py
Console._get_root
def _get_root(cls, order: Optional[str] = None) -> "Console": """Return a root console singleton with valid buffers. This function will also update an already active root console. """ global _root_console if _root_console is None: _root_console = object.__new__(cls) self = _root_console # type: Console if order is not None: self._order = order self.console_c = ffi.NULL self._init_setup_console_data(self._order) return self
python
def _get_root(cls, order: Optional[str] = None) -> "Console": """Return a root console singleton with valid buffers. This function will also update an already active root console. """ global _root_console if _root_console is None: _root_console = object.__new__(cls) self = _root_console # type: Console if order is not None: self._order = order self.console_c = ffi.NULL self._init_setup_console_data(self._order) return self
[ "def", "_get_root", "(", "cls", ",", "order", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "\"Console\"", ":", "global", "_root_console", "if", "_root_console", "is", "None", ":", "_root_console", "=", "object", ".", "__new__", "(", "cls", ")", "self", "=", "_root_console", "# type: Console", "if", "order", "is", "not", "None", ":", "self", ".", "_order", "=", "order", "self", ".", "console_c", "=", "ffi", ".", "NULL", "self", ".", "_init_setup_console_data", "(", "self", ".", "_order", ")", "return", "self" ]
Return a root console singleton with valid buffers. This function will also update an already active root console.
[ "Return", "a", "root", "console", "singleton", "with", "valid", "buffers", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L164-L177