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
partition
stringclasses
1 value
libtcod/python-tcod
tcod/path.py
_get_pathcost_func
def _get_pathcost_func( name: str ) -> Callable[[int, int, int, int, Any], float]: """Return a properly cast PathCostArray callback.""" return ffi.cast( # type: ignore "TCOD_path_func_t", ffi.addressof(lib, name) )
python
def _get_pathcost_func( name: str ) -> Callable[[int, int, int, int, Any], float]: """Return a properly cast PathCostArray callback.""" return ffi.cast( # type: ignore "TCOD_path_func_t", ffi.addressof(lib, name) )
[ "def", "_get_pathcost_func", "(", "name", ":", "str", ")", "->", "Callable", "[", "[", "int", ",", "int", ",", "int", ",", "int", ",", "Any", "]", ",", "float", "]", ":", "return", "ffi", ".", "cast", "(", "# type: ignore", "\"TCOD_path_func_t\"", ",", "ffi", ".", "addressof", "(", "lib", ",", "name", ")", ")" ]
Return a properly cast PathCostArray callback.
[ "Return", "a", "properly", "cast", "PathCostArray", "callback", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/path.py#L82-L88
train
libtcod/python-tcod
tcod/path.py
Dijkstra.set_goal
def set_goal(self, x: int, y: int) -> None: """Set the goal point and recompute the Dijkstra path-finder. """ lib.TCOD_dijkstra_compute(self._path_c, x, y)
python
def set_goal(self, x: int, y: int) -> None: """Set the goal point and recompute the Dijkstra path-finder. """ lib.TCOD_dijkstra_compute(self._path_c, x, y)
[ "def", "set_goal", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_dijkstra_compute", "(", "self", ".", "_path_c", ",", "x", ",", "y", ")" ]
Set the goal point and recompute the Dijkstra path-finder.
[ "Set", "the", "goal", "point", "and", "recompute", "the", "Dijkstra", "path", "-", "finder", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/path.py#L294-L297
train
libtcod/python-tcod
examples/termbox/termbox.py
Termbox.poll_event
def poll_event(self): """Wait for an event and return it. Returns a tuple: (type, unicode character, key, mod, width, height, mousex, mousey). """ """ cdef tb_event e with self._poll_lock: with nogil: result = tb_poll_event(&e) assert(result >= 0) if e.ch: uch = unichr(e.ch) else: uch = None """ for e in tdl.event.get(): # [ ] not all events are passed thru self.e.type = e.type if e.type == 'KEYDOWN': self.e.key = e.key return self.e.gettuple()
python
def poll_event(self): """Wait for an event and return it. Returns a tuple: (type, unicode character, key, mod, width, height, mousex, mousey). """ """ cdef tb_event e with self._poll_lock: with nogil: result = tb_poll_event(&e) assert(result >= 0) if e.ch: uch = unichr(e.ch) else: uch = None """ for e in tdl.event.get(): # [ ] not all events are passed thru self.e.type = e.type if e.type == 'KEYDOWN': self.e.key = e.key return self.e.gettuple()
[ "def", "poll_event", "(", "self", ")", ":", "\"\"\"\n cdef tb_event e\n with self._poll_lock:\n with nogil:\n result = tb_poll_event(&e)\n assert(result >= 0)\n if e.ch:\n uch = unichr(e.ch)\n else:\n uch = None\n \"\"\"", "for", "e", "in", "tdl", ".", "event", ".", "get", "(", ")", ":", "# [ ] not all events are passed thru", "self", ".", "e", ".", "type", "=", "e", ".", "type", "if", "e", ".", "type", "==", "'KEYDOWN'", ":", "self", ".", "e", ".", "key", "=", "e", ".", "key", "return", "self", ".", "e", ".", "gettuple", "(", ")" ]
Wait for an event and return it. Returns a tuple: (type, unicode character, key, mod, width, height, mousex, mousey).
[ "Wait", "for", "an", "event", "and", "return", "it", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/examples/termbox/termbox.py#L271-L293
train
libtcod/python-tcod
tcod/random.py
Random._new_from_cdata
def _new_from_cdata(cls, cdata: Any) -> "Random": """Return a new instance encapsulating this cdata.""" self = object.__new__(cls) # type: "Random" self.random_c = cdata return self
python
def _new_from_cdata(cls, cdata: Any) -> "Random": """Return a new instance encapsulating this cdata.""" self = object.__new__(cls) # type: "Random" self.random_c = cdata return self
[ "def", "_new_from_cdata", "(", "cls", ",", "cdata", ":", "Any", ")", "->", "\"Random\"", ":", "self", "=", "object", ".", "__new__", "(", "cls", ")", "# type: \"Random\"", "self", ".", "random_c", "=", "cdata", "return", "self" ]
Return a new instance encapsulating this cdata.
[ "Return", "a", "new", "instance", "encapsulating", "this", "cdata", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/random.py#L58-L62
train
libtcod/python-tcod
tcod/random.py
Random.guass
def guass(self, mu: float, sigma: float) -> float: """Return a random number using Gaussian distribution. Args: mu (float): The median returned value. sigma (float): The standard deviation. Returns: float: A random float. """ return float( lib.TCOD_random_get_gaussian_double(self.random_c, mu, sigma) )
python
def guass(self, mu: float, sigma: float) -> float: """Return a random number using Gaussian distribution. Args: mu (float): The median returned value. sigma (float): The standard deviation. Returns: float: A random float. """ return float( lib.TCOD_random_get_gaussian_double(self.random_c, mu, sigma) )
[ "def", "guass", "(", "self", ",", "mu", ":", "float", ",", "sigma", ":", "float", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_random_get_gaussian_double", "(", "self", ".", "random_c", ",", "mu", ",", "sigma", ")", ")" ]
Return a random number using Gaussian distribution. Args: mu (float): The median returned value. sigma (float): The standard deviation. Returns: float: A random float.
[ "Return", "a", "random", "number", "using", "Gaussian", "distribution", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/random.py#L88-L100
train
libtcod/python-tcod
tcod/random.py
Random.inverse_guass
def inverse_guass(self, mu: float, sigma: float) -> float: """Return a random Gaussian number using the Box-Muller transform. Args: mu (float): The median returned value. sigma (float): The standard deviation. Returns: float: A random float. """ return float( lib.TCOD_random_get_gaussian_double_inv(self.random_c, mu, sigma) )
python
def inverse_guass(self, mu: float, sigma: float) -> float: """Return a random Gaussian number using the Box-Muller transform. Args: mu (float): The median returned value. sigma (float): The standard deviation. Returns: float: A random float. """ return float( lib.TCOD_random_get_gaussian_double_inv(self.random_c, mu, sigma) )
[ "def", "inverse_guass", "(", "self", ",", "mu", ":", "float", ",", "sigma", ":", "float", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_random_get_gaussian_double_inv", "(", "self", ".", "random_c", ",", "mu", ",", "sigma", ")", ")" ]
Return a random Gaussian number using the Box-Muller transform. Args: mu (float): The median returned value. sigma (float): The standard deviation. Returns: float: A random float.
[ "Return", "a", "random", "Gaussian", "number", "using", "the", "Box", "-", "Muller", "transform", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/random.py#L102-L114
train
libtcod/python-tcod
tdl/noise.py
Noise.get_point
def get_point(self, *position): """Return the noise value of a specific position. Example usage: value = noise.getPoint(x, y, z) Args: position (Tuple[float, ...]): The point to sample at. Returns: float: The noise value at position. This will be a floating point in the 0.0-1.0 range. """ #array = self._array #for d, pos in enumerate(position): # array[d] = pos #array = self._cFloatArray(*position) array = _ffi.new(self._arrayType, position) if self._useOctaves: return (self._noiseFunc(self._noise, array, self._octaves) + 1) * 0.5 return (self._noiseFunc(self._noise, array) + 1) * 0.5
python
def get_point(self, *position): """Return the noise value of a specific position. Example usage: value = noise.getPoint(x, y, z) Args: position (Tuple[float, ...]): The point to sample at. Returns: float: The noise value at position. This will be a floating point in the 0.0-1.0 range. """ #array = self._array #for d, pos in enumerate(position): # array[d] = pos #array = self._cFloatArray(*position) array = _ffi.new(self._arrayType, position) if self._useOctaves: return (self._noiseFunc(self._noise, array, self._octaves) + 1) * 0.5 return (self._noiseFunc(self._noise, array) + 1) * 0.5
[ "def", "get_point", "(", "self", ",", "*", "position", ")", ":", "#array = self._array", "#for d, pos in enumerate(position):", "# array[d] = pos", "#array = self._cFloatArray(*position)", "array", "=", "_ffi", ".", "new", "(", "self", ".", "_arrayType", ",", "position", ")", "if", "self", ".", "_useOctaves", ":", "return", "(", "self", ".", "_noiseFunc", "(", "self", ".", "_noise", ",", "array", ",", "self", ".", "_octaves", ")", "+", "1", ")", "*", "0.5", "return", "(", "self", ".", "_noiseFunc", "(", "self", ".", "_noise", ",", "array", ")", "+", "1", ")", "*", "0.5" ]
Return the noise value of a specific position. Example usage: value = noise.getPoint(x, y, z) Args: position (Tuple[float, ...]): The point to sample at. Returns: float: The noise value at position. This will be a floating point in the 0.0-1.0 range.
[ "Return", "the", "noise", "value", "of", "a", "specific", "position", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/noise.py#L144-L164
train
libtcod/python-tcod
tcod/map.py
compute_fov
def compute_fov( transparency: np.array, x: int, y: int, radius: int = 0, light_walls: bool = True, algorithm: int = tcod.constants.FOV_RESTRICTIVE, ) -> np.array: """Return the visible area of a field-of-view computation. `transparency` is a 2 dimensional array where all non-zero values are considered transparent. The returned array will match the shape of this array. `x` and `y` are the 1st and 2nd coordinates of the origin point. Areas are visible when they can be seen from this point-of-view. `radius` is the maximum view distance from `x`/`y`. If this is zero then the maximum distance is used. If `light_walls` is True then visible obstacles will be returned, otherwise only transparent areas will be. `algorithm` is the field-of-view algorithm to run. The default value is `tcod.FOV_RESTRICTIVE`. The options are: * `tcod.FOV_BASIC`: Simple ray-cast implementation. * `tcod.FOV_DIAMOND` * `tcod.FOV_SHADOW`: Recursive shadow caster. * `tcod.FOV_PERMISSIVE(n)`: `n` starts at 0 (most restrictive) and goes up to 8 (most permissive.) * `tcod.FOV_RESTRICTIVE` .. versionadded:: 9.3 Example:: >>> explored = np.zeros((3, 5), dtype=bool, order="F") >>> transparency = np.ones((3, 5), dtype=bool, order="F") >>> transparency[:2, 2] = False >>> transparency # Transparent area. array([[ True, True, False, True, True], [ True, True, False, True, True], [ True, True, True, True, True]]...) >>> visible = tcod.map.compute_fov(transparency, 0, 0) >>> visible # Visible area. array([[ True, True, True, False, False], [ True, True, True, False, False], [ True, True, True, True, False]]...) >>> explored |= visible # Keep track of an explored area. """ if len(transparency.shape) != 2: raise TypeError( "transparency must be an array of 2 dimensions" " (shape is %r)" % transparency.shape ) map_ = Map(transparency.shape[1], transparency.shape[0]) map_.transparent[...] = transparency map_.compute_fov(x, y, radius, light_walls, algorithm) return map_.fov
python
def compute_fov( transparency: np.array, x: int, y: int, radius: int = 0, light_walls: bool = True, algorithm: int = tcod.constants.FOV_RESTRICTIVE, ) -> np.array: """Return the visible area of a field-of-view computation. `transparency` is a 2 dimensional array where all non-zero values are considered transparent. The returned array will match the shape of this array. `x` and `y` are the 1st and 2nd coordinates of the origin point. Areas are visible when they can be seen from this point-of-view. `radius` is the maximum view distance from `x`/`y`. If this is zero then the maximum distance is used. If `light_walls` is True then visible obstacles will be returned, otherwise only transparent areas will be. `algorithm` is the field-of-view algorithm to run. The default value is `tcod.FOV_RESTRICTIVE`. The options are: * `tcod.FOV_BASIC`: Simple ray-cast implementation. * `tcod.FOV_DIAMOND` * `tcod.FOV_SHADOW`: Recursive shadow caster. * `tcod.FOV_PERMISSIVE(n)`: `n` starts at 0 (most restrictive) and goes up to 8 (most permissive.) * `tcod.FOV_RESTRICTIVE` .. versionadded:: 9.3 Example:: >>> explored = np.zeros((3, 5), dtype=bool, order="F") >>> transparency = np.ones((3, 5), dtype=bool, order="F") >>> transparency[:2, 2] = False >>> transparency # Transparent area. array([[ True, True, False, True, True], [ True, True, False, True, True], [ True, True, True, True, True]]...) >>> visible = tcod.map.compute_fov(transparency, 0, 0) >>> visible # Visible area. array([[ True, True, True, False, False], [ True, True, True, False, False], [ True, True, True, True, False]]...) >>> explored |= visible # Keep track of an explored area. """ if len(transparency.shape) != 2: raise TypeError( "transparency must be an array of 2 dimensions" " (shape is %r)" % transparency.shape ) map_ = Map(transparency.shape[1], transparency.shape[0]) map_.transparent[...] = transparency map_.compute_fov(x, y, radius, light_walls, algorithm) return map_.fov
[ "def", "compute_fov", "(", "transparency", ":", "np", ".", "array", ",", "x", ":", "int", ",", "y", ":", "int", ",", "radius", ":", "int", "=", "0", ",", "light_walls", ":", "bool", "=", "True", ",", "algorithm", ":", "int", "=", "tcod", ".", "constants", ".", "FOV_RESTRICTIVE", ",", ")", "->", "np", ".", "array", ":", "if", "len", "(", "transparency", ".", "shape", ")", "!=", "2", ":", "raise", "TypeError", "(", "\"transparency must be an array of 2 dimensions\"", "\" (shape is %r)\"", "%", "transparency", ".", "shape", ")", "map_", "=", "Map", "(", "transparency", ".", "shape", "[", "1", "]", ",", "transparency", ".", "shape", "[", "0", "]", ")", "map_", ".", "transparent", "[", "...", "]", "=", "transparency", "map_", ".", "compute_fov", "(", "x", ",", "y", ",", "radius", ",", "light_walls", ",", "algorithm", ")", "return", "map_", ".", "fov" ]
Return the visible area of a field-of-view computation. `transparency` is a 2 dimensional array where all non-zero values are considered transparent. The returned array will match the shape of this array. `x` and `y` are the 1st and 2nd coordinates of the origin point. Areas are visible when they can be seen from this point-of-view. `radius` is the maximum view distance from `x`/`y`. If this is zero then the maximum distance is used. If `light_walls` is True then visible obstacles will be returned, otherwise only transparent areas will be. `algorithm` is the field-of-view algorithm to run. The default value is `tcod.FOV_RESTRICTIVE`. The options are: * `tcod.FOV_BASIC`: Simple ray-cast implementation. * `tcod.FOV_DIAMOND` * `tcod.FOV_SHADOW`: Recursive shadow caster. * `tcod.FOV_PERMISSIVE(n)`: `n` starts at 0 (most restrictive) and goes up to 8 (most permissive.) * `tcod.FOV_RESTRICTIVE` .. versionadded:: 9.3 Example:: >>> explored = np.zeros((3, 5), dtype=bool, order="F") >>> transparency = np.ones((3, 5), dtype=bool, order="F") >>> transparency[:2, 2] = False >>> transparency # Transparent area. array([[ True, True, False, True, True], [ True, True, False, True, True], [ True, True, True, True, True]]...) >>> visible = tcod.map.compute_fov(transparency, 0, 0) >>> visible # Visible area. array([[ True, True, True, False, False], [ True, True, True, False, False], [ True, True, True, True, False]]...) >>> explored |= visible # Keep track of an explored area.
[ "Return", "the", "visible", "area", "of", "a", "field", "-", "of", "-", "view", "computation", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/map.py#L147-L209
train
libtcod/python-tcod
tcod/map.py
Map.compute_fov
def compute_fov( self, x: int, y: int, radius: int = 0, light_walls: bool = True, algorithm: int = tcod.constants.FOV_RESTRICTIVE, ) -> None: """Compute a field-of-view on the current instance. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. radius (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. algorithm (int): Defaults to tcod.FOV_RESTRICTIVE If you already have transparency in a NumPy array then you could use :any:`tcod.map_compute_fov` instead. """ lib.TCOD_map_compute_fov( self.map_c, x, y, radius, light_walls, algorithm )
python
def compute_fov( self, x: int, y: int, radius: int = 0, light_walls: bool = True, algorithm: int = tcod.constants.FOV_RESTRICTIVE, ) -> None: """Compute a field-of-view on the current instance. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. radius (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. algorithm (int): Defaults to tcod.FOV_RESTRICTIVE If you already have transparency in a NumPy array then you could use :any:`tcod.map_compute_fov` instead. """ lib.TCOD_map_compute_fov( self.map_c, x, y, radius, light_walls, algorithm )
[ "def", "compute_fov", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "radius", ":", "int", "=", "0", ",", "light_walls", ":", "bool", "=", "True", ",", "algorithm", ":", "int", "=", "tcod", ".", "constants", ".", "FOV_RESTRICTIVE", ",", ")", "->", "None", ":", "lib", ".", "TCOD_map_compute_fov", "(", "self", ".", "map_c", ",", "x", ",", "y", ",", "radius", ",", "light_walls", ",", "algorithm", ")" ]
Compute a field-of-view on the current instance. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. radius (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. algorithm (int): Defaults to tcod.FOV_RESTRICTIVE If you already have transparency in a NumPy array then you could use :any:`tcod.map_compute_fov` instead.
[ "Compute", "a", "field", "-", "of", "-", "view", "on", "the", "current", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/map.py#L99-L123
train
libtcod/python-tcod
tcod/noise.py
Noise.sample_mgrid
def sample_mgrid(self, mgrid: np.array) -> np.array: """Sample a mesh-grid array and return the result. The :any:`sample_ogrid` method performs better as there is a lot of overhead when working with large mesh-grids. Args: mgrid (numpy.ndarray): A mesh-grid array of points to sample. A contiguous array of type `numpy.float32` is preferred. Returns: numpy.ndarray: An array of sampled points. This array has the shape: ``mgrid.shape[:-1]``. The ``dtype`` is `numpy.float32`. """ mgrid = np.ascontiguousarray(mgrid, np.float32) if mgrid.shape[0] != self.dimensions: raise ValueError( "mgrid.shape[0] must equal self.dimensions, " "%r[0] != %r" % (mgrid.shape, self.dimensions) ) out = np.ndarray(mgrid.shape[1:], np.float32) if mgrid.shape[1:] != out.shape: raise ValueError( "mgrid.shape[1:] must equal out.shape, " "%r[1:] != %r" % (mgrid.shape, out.shape) ) lib.NoiseSampleMeshGrid( self._tdl_noise_c, out.size, ffi.cast("float*", mgrid.ctypes.data), ffi.cast("float*", out.ctypes.data), ) return out
python
def sample_mgrid(self, mgrid: np.array) -> np.array: """Sample a mesh-grid array and return the result. The :any:`sample_ogrid` method performs better as there is a lot of overhead when working with large mesh-grids. Args: mgrid (numpy.ndarray): A mesh-grid array of points to sample. A contiguous array of type `numpy.float32` is preferred. Returns: numpy.ndarray: An array of sampled points. This array has the shape: ``mgrid.shape[:-1]``. The ``dtype`` is `numpy.float32`. """ mgrid = np.ascontiguousarray(mgrid, np.float32) if mgrid.shape[0] != self.dimensions: raise ValueError( "mgrid.shape[0] must equal self.dimensions, " "%r[0] != %r" % (mgrid.shape, self.dimensions) ) out = np.ndarray(mgrid.shape[1:], np.float32) if mgrid.shape[1:] != out.shape: raise ValueError( "mgrid.shape[1:] must equal out.shape, " "%r[1:] != %r" % (mgrid.shape, out.shape) ) lib.NoiseSampleMeshGrid( self._tdl_noise_c, out.size, ffi.cast("float*", mgrid.ctypes.data), ffi.cast("float*", out.ctypes.data), ) return out
[ "def", "sample_mgrid", "(", "self", ",", "mgrid", ":", "np", ".", "array", ")", "->", "np", ".", "array", ":", "mgrid", "=", "np", ".", "ascontiguousarray", "(", "mgrid", ",", "np", ".", "float32", ")", "if", "mgrid", ".", "shape", "[", "0", "]", "!=", "self", ".", "dimensions", ":", "raise", "ValueError", "(", "\"mgrid.shape[0] must equal self.dimensions, \"", "\"%r[0] != %r\"", "%", "(", "mgrid", ".", "shape", ",", "self", ".", "dimensions", ")", ")", "out", "=", "np", ".", "ndarray", "(", "mgrid", ".", "shape", "[", "1", ":", "]", ",", "np", ".", "float32", ")", "if", "mgrid", ".", "shape", "[", "1", ":", "]", "!=", "out", ".", "shape", ":", "raise", "ValueError", "(", "\"mgrid.shape[1:] must equal out.shape, \"", "\"%r[1:] != %r\"", "%", "(", "mgrid", ".", "shape", ",", "out", ".", "shape", ")", ")", "lib", ".", "NoiseSampleMeshGrid", "(", "self", ".", "_tdl_noise_c", ",", "out", ".", "size", ",", "ffi", ".", "cast", "(", "\"float*\"", ",", "mgrid", ".", "ctypes", ".", "data", ")", ",", "ffi", ".", "cast", "(", "\"float*\"", ",", "out", ".", "ctypes", ".", "data", ")", ",", ")", "return", "out" ]
Sample a mesh-grid array and return the result. The :any:`sample_ogrid` method performs better as there is a lot of overhead when working with large mesh-grids. Args: mgrid (numpy.ndarray): A mesh-grid array of points to sample. A contiguous array of type `numpy.float32` is preferred. Returns: numpy.ndarray: An array of sampled points. This array has the shape: ``mgrid.shape[:-1]``. The ``dtype`` is `numpy.float32`.
[ "Sample", "a", "mesh", "-", "grid", "array", "and", "return", "the", "result", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/noise.py#L162-L196
train
libtcod/python-tcod
tcod/noise.py
Noise.sample_ogrid
def sample_ogrid(self, ogrid: np.array) -> np.array: """Sample an open mesh-grid array and return the result. Args ogrid (Sequence[Sequence[float]]): An open mesh-grid. Returns: numpy.ndarray: An array of sampled points. The ``shape`` is based on the lengths of the open mesh-grid arrays. The ``dtype`` is `numpy.float32`. """ if len(ogrid) != self.dimensions: raise ValueError( "len(ogrid) must equal self.dimensions, " "%r != %r" % (len(ogrid), self.dimensions) ) ogrids = [np.ascontiguousarray(array, np.float32) for array in ogrid] out = np.ndarray([array.size for array in ogrids], np.float32) lib.NoiseSampleOpenMeshGrid( self._tdl_noise_c, len(ogrids), out.shape, [ffi.cast("float*", array.ctypes.data) for array in ogrids], ffi.cast("float*", out.ctypes.data), ) return out
python
def sample_ogrid(self, ogrid: np.array) -> np.array: """Sample an open mesh-grid array and return the result. Args ogrid (Sequence[Sequence[float]]): An open mesh-grid. Returns: numpy.ndarray: An array of sampled points. The ``shape`` is based on the lengths of the open mesh-grid arrays. The ``dtype`` is `numpy.float32`. """ if len(ogrid) != self.dimensions: raise ValueError( "len(ogrid) must equal self.dimensions, " "%r != %r" % (len(ogrid), self.dimensions) ) ogrids = [np.ascontiguousarray(array, np.float32) for array in ogrid] out = np.ndarray([array.size for array in ogrids], np.float32) lib.NoiseSampleOpenMeshGrid( self._tdl_noise_c, len(ogrids), out.shape, [ffi.cast("float*", array.ctypes.data) for array in ogrids], ffi.cast("float*", out.ctypes.data), ) return out
[ "def", "sample_ogrid", "(", "self", ",", "ogrid", ":", "np", ".", "array", ")", "->", "np", ".", "array", ":", "if", "len", "(", "ogrid", ")", "!=", "self", ".", "dimensions", ":", "raise", "ValueError", "(", "\"len(ogrid) must equal self.dimensions, \"", "\"%r != %r\"", "%", "(", "len", "(", "ogrid", ")", ",", "self", ".", "dimensions", ")", ")", "ogrids", "=", "[", "np", ".", "ascontiguousarray", "(", "array", ",", "np", ".", "float32", ")", "for", "array", "in", "ogrid", "]", "out", "=", "np", ".", "ndarray", "(", "[", "array", ".", "size", "for", "array", "in", "ogrids", "]", ",", "np", ".", "float32", ")", "lib", ".", "NoiseSampleOpenMeshGrid", "(", "self", ".", "_tdl_noise_c", ",", "len", "(", "ogrids", ")", ",", "out", ".", "shape", ",", "[", "ffi", ".", "cast", "(", "\"float*\"", ",", "array", ".", "ctypes", ".", "data", ")", "for", "array", "in", "ogrids", "]", ",", "ffi", ".", "cast", "(", "\"float*\"", ",", "out", ".", "ctypes", ".", "data", ")", ",", ")", "return", "out" ]
Sample an open mesh-grid array and return the result. Args ogrid (Sequence[Sequence[float]]): An open mesh-grid. Returns: numpy.ndarray: An array of sampled points. The ``shape`` is based on the lengths of the open mesh-grid arrays. The ``dtype`` is `numpy.float32`.
[ "Sample", "an", "open", "mesh", "-", "grid", "array", "and", "return", "the", "result", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/noise.py#L198-L225
train
libtcod/python-tcod
tdl/event.py
_processEvents
def _processEvents(): """Flushes the event queue from libtcod into the global list _eventQueue""" global _mousel, _mousem, _mouser, _eventsflushed, _pushedEvents _eventsflushed = True events = _pushedEvents # get events from event.push _pushedEvents = [] # then clear the pushed events queue mouse = _ffi.new('TCOD_mouse_t *') libkey = _ffi.new('TCOD_key_t *') while 1: libevent = _lib.TCOD_sys_check_for_event(_lib.TCOD_EVENT_ANY, libkey, mouse) if not libevent: # no more events from libtcod break #if mouse.dx or mouse.dy: if libevent & _lib.TCOD_EVENT_MOUSE_MOVE: events.append(MouseMotion((mouse.x, mouse.y), (mouse.cx, mouse.cy), (mouse.dx, mouse.dy), (mouse.dcx, mouse.dcy))) mousepos = ((mouse.x, mouse.y), (mouse.cx, mouse.cy)) for oldstate, newstate, released, button in \ zip((_mousel, _mousem, _mouser), (mouse.lbutton, mouse.mbutton, mouse.rbutton), (mouse.lbutton_pressed, mouse.mbutton_pressed, mouse.rbutton_pressed), (1, 2, 3)): if released: if not oldstate: events.append(MouseDown(button, *mousepos)) events.append(MouseUp(button, *mousepos)) if newstate: events.append(MouseDown(button, *mousepos)) elif newstate and not oldstate: events.append(MouseDown(button, *mousepos)) if mouse.wheel_up: events.append(MouseDown(4, *mousepos)) if mouse.wheel_down: events.append(MouseDown(5, *mousepos)) _mousel = mouse.lbutton _mousem = mouse.mbutton _mouser = mouse.rbutton if libkey.vk == _lib.TCODK_NONE: break if libkey.pressed: keyevent = KeyDown else: keyevent = KeyUp events.append( keyevent( libkey.vk, libkey.c.decode('ascii', errors='ignore'), _ffi.string(libkey.text).decode('utf-8'), libkey.shift, libkey.lalt, libkey.ralt, libkey.lctrl, libkey.rctrl, libkey.lmeta, libkey.rmeta, ) ) if _lib.TCOD_console_is_window_closed(): events.append(Quit()) _eventQueue.extend(events)
python
def _processEvents(): """Flushes the event queue from libtcod into the global list _eventQueue""" global _mousel, _mousem, _mouser, _eventsflushed, _pushedEvents _eventsflushed = True events = _pushedEvents # get events from event.push _pushedEvents = [] # then clear the pushed events queue mouse = _ffi.new('TCOD_mouse_t *') libkey = _ffi.new('TCOD_key_t *') while 1: libevent = _lib.TCOD_sys_check_for_event(_lib.TCOD_EVENT_ANY, libkey, mouse) if not libevent: # no more events from libtcod break #if mouse.dx or mouse.dy: if libevent & _lib.TCOD_EVENT_MOUSE_MOVE: events.append(MouseMotion((mouse.x, mouse.y), (mouse.cx, mouse.cy), (mouse.dx, mouse.dy), (mouse.dcx, mouse.dcy))) mousepos = ((mouse.x, mouse.y), (mouse.cx, mouse.cy)) for oldstate, newstate, released, button in \ zip((_mousel, _mousem, _mouser), (mouse.lbutton, mouse.mbutton, mouse.rbutton), (mouse.lbutton_pressed, mouse.mbutton_pressed, mouse.rbutton_pressed), (1, 2, 3)): if released: if not oldstate: events.append(MouseDown(button, *mousepos)) events.append(MouseUp(button, *mousepos)) if newstate: events.append(MouseDown(button, *mousepos)) elif newstate and not oldstate: events.append(MouseDown(button, *mousepos)) if mouse.wheel_up: events.append(MouseDown(4, *mousepos)) if mouse.wheel_down: events.append(MouseDown(5, *mousepos)) _mousel = mouse.lbutton _mousem = mouse.mbutton _mouser = mouse.rbutton if libkey.vk == _lib.TCODK_NONE: break if libkey.pressed: keyevent = KeyDown else: keyevent = KeyUp events.append( keyevent( libkey.vk, libkey.c.decode('ascii', errors='ignore'), _ffi.string(libkey.text).decode('utf-8'), libkey.shift, libkey.lalt, libkey.ralt, libkey.lctrl, libkey.rctrl, libkey.lmeta, libkey.rmeta, ) ) if _lib.TCOD_console_is_window_closed(): events.append(Quit()) _eventQueue.extend(events)
[ "def", "_processEvents", "(", ")", ":", "global", "_mousel", ",", "_mousem", ",", "_mouser", ",", "_eventsflushed", ",", "_pushedEvents", "_eventsflushed", "=", "True", "events", "=", "_pushedEvents", "# get events from event.push", "_pushedEvents", "=", "[", "]", "# then clear the pushed events queue", "mouse", "=", "_ffi", ".", "new", "(", "'TCOD_mouse_t *'", ")", "libkey", "=", "_ffi", ".", "new", "(", "'TCOD_key_t *'", ")", "while", "1", ":", "libevent", "=", "_lib", ".", "TCOD_sys_check_for_event", "(", "_lib", ".", "TCOD_EVENT_ANY", ",", "libkey", ",", "mouse", ")", "if", "not", "libevent", ":", "# no more events from libtcod", "break", "#if mouse.dx or mouse.dy:", "if", "libevent", "&", "_lib", ".", "TCOD_EVENT_MOUSE_MOVE", ":", "events", ".", "append", "(", "MouseMotion", "(", "(", "mouse", ".", "x", ",", "mouse", ".", "y", ")", ",", "(", "mouse", ".", "cx", ",", "mouse", ".", "cy", ")", ",", "(", "mouse", ".", "dx", ",", "mouse", ".", "dy", ")", ",", "(", "mouse", ".", "dcx", ",", "mouse", ".", "dcy", ")", ")", ")", "mousepos", "=", "(", "(", "mouse", ".", "x", ",", "mouse", ".", "y", ")", ",", "(", "mouse", ".", "cx", ",", "mouse", ".", "cy", ")", ")", "for", "oldstate", ",", "newstate", ",", "released", ",", "button", "in", "zip", "(", "(", "_mousel", ",", "_mousem", ",", "_mouser", ")", ",", "(", "mouse", ".", "lbutton", ",", "mouse", ".", "mbutton", ",", "mouse", ".", "rbutton", ")", ",", "(", "mouse", ".", "lbutton_pressed", ",", "mouse", ".", "mbutton_pressed", ",", "mouse", ".", "rbutton_pressed", ")", ",", "(", "1", ",", "2", ",", "3", ")", ")", ":", "if", "released", ":", "if", "not", "oldstate", ":", "events", ".", "append", "(", "MouseDown", "(", "button", ",", "*", "mousepos", ")", ")", "events", ".", "append", "(", "MouseUp", "(", "button", ",", "*", "mousepos", ")", ")", "if", "newstate", ":", "events", ".", "append", "(", "MouseDown", "(", "button", ",", "*", "mousepos", ")", ")", "elif", "newstate", "and", "not", "oldstate", ":", "events", ".", "append", "(", "MouseDown", "(", "button", ",", "*", "mousepos", ")", ")", "if", "mouse", ".", "wheel_up", ":", "events", ".", "append", "(", "MouseDown", "(", "4", ",", "*", "mousepos", ")", ")", "if", "mouse", ".", "wheel_down", ":", "events", ".", "append", "(", "MouseDown", "(", "5", ",", "*", "mousepos", ")", ")", "_mousel", "=", "mouse", ".", "lbutton", "_mousem", "=", "mouse", ".", "mbutton", "_mouser", "=", "mouse", ".", "rbutton", "if", "libkey", ".", "vk", "==", "_lib", ".", "TCODK_NONE", ":", "break", "if", "libkey", ".", "pressed", ":", "keyevent", "=", "KeyDown", "else", ":", "keyevent", "=", "KeyUp", "events", ".", "append", "(", "keyevent", "(", "libkey", ".", "vk", ",", "libkey", ".", "c", ".", "decode", "(", "'ascii'", ",", "errors", "=", "'ignore'", ")", ",", "_ffi", ".", "string", "(", "libkey", ".", "text", ")", ".", "decode", "(", "'utf-8'", ")", ",", "libkey", ".", "shift", ",", "libkey", ".", "lalt", ",", "libkey", ".", "ralt", ",", "libkey", ".", "lctrl", ",", "libkey", ".", "rctrl", ",", "libkey", ".", "lmeta", ",", "libkey", ".", "rmeta", ",", ")", ")", "if", "_lib", ".", "TCOD_console_is_window_closed", "(", ")", ":", "events", ".", "append", "(", "Quit", "(", ")", ")", "_eventQueue", ".", "extend", "(", "events", ")" ]
Flushes the event queue from libtcod into the global list _eventQueue
[ "Flushes", "the", "event", "queue", "from", "libtcod", "into", "the", "global", "list", "_eventQueue" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/event.py#L331-L403
train
libtcod/python-tcod
tdl/event.py
wait
def wait(timeout=None, flush=True): """Wait for an event. Args: timeout (Optional[int]): The time in seconds that this function will wait before giving up and returning None. With the default value of None, this will block forever. flush (bool): If True a call to :any:`tdl.flush` will be made before listening for events. Returns: Type[Event]: An event, or None if the function has timed out. Anything added via :any:`push` will also be returned. """ if timeout is not None: timeout = timeout + _time.clock() # timeout at this time while True: if _eventQueue: return _eventQueue.pop(0) if flush: # a full 'round' of events need to be processed before flushing _tdl.flush() if timeout and _time.clock() >= timeout: return None # return None on timeout _time.sleep(0.001) # sleep 1ms _processEvents()
python
def wait(timeout=None, flush=True): """Wait for an event. Args: timeout (Optional[int]): The time in seconds that this function will wait before giving up and returning None. With the default value of None, this will block forever. flush (bool): If True a call to :any:`tdl.flush` will be made before listening for events. Returns: Type[Event]: An event, or None if the function has timed out. Anything added via :any:`push` will also be returned. """ if timeout is not None: timeout = timeout + _time.clock() # timeout at this time while True: if _eventQueue: return _eventQueue.pop(0) if flush: # a full 'round' of events need to be processed before flushing _tdl.flush() if timeout and _time.clock() >= timeout: return None # return None on timeout _time.sleep(0.001) # sleep 1ms _processEvents()
[ "def", "wait", "(", "timeout", "=", "None", ",", "flush", "=", "True", ")", ":", "if", "timeout", "is", "not", "None", ":", "timeout", "=", "timeout", "+", "_time", ".", "clock", "(", ")", "# timeout at this time", "while", "True", ":", "if", "_eventQueue", ":", "return", "_eventQueue", ".", "pop", "(", "0", ")", "if", "flush", ":", "# a full 'round' of events need to be processed before flushing", "_tdl", ".", "flush", "(", ")", "if", "timeout", "and", "_time", ".", "clock", "(", ")", ">=", "timeout", ":", "return", "None", "# return None on timeout", "_time", ".", "sleep", "(", "0.001", ")", "# sleep 1ms", "_processEvents", "(", ")" ]
Wait for an event. Args: timeout (Optional[int]): The time in seconds that this function will wait before giving up and returning None. With the default value of None, this will block forever. flush (bool): If True a call to :any:`tdl.flush` will be made before listening for events. Returns: Type[Event]: An event, or None if the function has timed out. Anything added via :any:`push` will also be returned.
[ "Wait", "for", "an", "event", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/event.py#L428-L454
train
libtcod/python-tcod
tdl/event.py
App.run_once
def run_once(self): """Pump events to this App instance and then return. This works in the way described in :any:`App.run` except it immediately returns after the first :any:`update` call. Having multiple :any:`App` instances and selectively calling runOnce on them is a decent way to create a state machine. """ if not hasattr(self, '_App__prevTime'): self.__prevTime = _time.clock() # initiate __prevTime for event in get(): if event.type: # exclude custom events with a blank type variable # call the ev_* methods method = 'ev_%s' % event.type # ev_TYPE getattr(self, method)(event) if event.type == 'KEYDOWN': # call the key_* methods method = 'key_%s' % event.key # key_KEYNAME if hasattr(self, method): # silently exclude undefined methods getattr(self, method)(event) newTime = _time.clock() self.update(newTime - self.__prevTime) self.__prevTime = newTime
python
def run_once(self): """Pump events to this App instance and then return. This works in the way described in :any:`App.run` except it immediately returns after the first :any:`update` call. Having multiple :any:`App` instances and selectively calling runOnce on them is a decent way to create a state machine. """ if not hasattr(self, '_App__prevTime'): self.__prevTime = _time.clock() # initiate __prevTime for event in get(): if event.type: # exclude custom events with a blank type variable # call the ev_* methods method = 'ev_%s' % event.type # ev_TYPE getattr(self, method)(event) if event.type == 'KEYDOWN': # call the key_* methods method = 'key_%s' % event.key # key_KEYNAME if hasattr(self, method): # silently exclude undefined methods getattr(self, method)(event) newTime = _time.clock() self.update(newTime - self.__prevTime) self.__prevTime = newTime
[ "def", "run_once", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_App__prevTime'", ")", ":", "self", ".", "__prevTime", "=", "_time", ".", "clock", "(", ")", "# initiate __prevTime", "for", "event", "in", "get", "(", ")", ":", "if", "event", ".", "type", ":", "# exclude custom events with a blank type variable", "# call the ev_* methods", "method", "=", "'ev_%s'", "%", "event", ".", "type", "# ev_TYPE", "getattr", "(", "self", ",", "method", ")", "(", "event", ")", "if", "event", ".", "type", "==", "'KEYDOWN'", ":", "# call the key_* methods", "method", "=", "'key_%s'", "%", "event", ".", "key", "# key_KEYNAME", "if", "hasattr", "(", "self", ",", "method", ")", ":", "# silently exclude undefined methods", "getattr", "(", "self", ",", "method", ")", "(", "event", ")", "newTime", "=", "_time", ".", "clock", "(", ")", "self", ".", "update", "(", "newTime", "-", "self", ".", "__prevTime", ")", "self", ".", "__prevTime", "=", "newTime" ]
Pump events to this App instance and then return. This works in the way described in :any:`App.run` except it immediately returns after the first :any:`update` call. Having multiple :any:`App` instances and selectively calling runOnce on them is a decent way to create a state machine.
[ "Pump", "events", "to", "this", "App", "instance", "and", "then", "return", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/event.py#L305-L328
train
libtcod/python-tcod
tcod/tileset.py
load_truetype_font
def load_truetype_font( path: str, tile_width: int, tile_height: int ) -> Tileset: """Return a new Tileset from a `.ttf` or `.otf` file. Same as :any:`set_truetype_font`, but returns a :any:`Tileset` instead. You can send this Tileset to :any:`set_default`. This function is provisional. The API may change. """ if not os.path.exists(path): raise RuntimeError("File not found:\n\t%s" % (os.path.realpath(path),)) return Tileset._claim( lib.TCOD_load_truetype_font_(path.encode(), tile_width, tile_height) )
python
def load_truetype_font( path: str, tile_width: int, tile_height: int ) -> Tileset: """Return a new Tileset from a `.ttf` or `.otf` file. Same as :any:`set_truetype_font`, but returns a :any:`Tileset` instead. You can send this Tileset to :any:`set_default`. This function is provisional. The API may change. """ if not os.path.exists(path): raise RuntimeError("File not found:\n\t%s" % (os.path.realpath(path),)) return Tileset._claim( lib.TCOD_load_truetype_font_(path.encode(), tile_width, tile_height) )
[ "def", "load_truetype_font", "(", "path", ":", "str", ",", "tile_width", ":", "int", ",", "tile_height", ":", "int", ")", "->", "Tileset", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "RuntimeError", "(", "\"File not found:\\n\\t%s\"", "%", "(", "os", ".", "path", ".", "realpath", "(", "path", ")", ",", ")", ")", "return", "Tileset", ".", "_claim", "(", "lib", ".", "TCOD_load_truetype_font_", "(", "path", ".", "encode", "(", ")", ",", "tile_width", ",", "tile_height", ")", ")" ]
Return a new Tileset from a `.ttf` or `.otf` file. Same as :any:`set_truetype_font`, but returns a :any:`Tileset` instead. You can send this Tileset to :any:`set_default`. This function is provisional. The API may change.
[ "Return", "a", "new", "Tileset", "from", "a", ".", "ttf", "or", ".", "otf", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/tileset.py#L120-L134
train
libtcod/python-tcod
tcod/tileset.py
set_truetype_font
def set_truetype_font(path: str, tile_width: int, tile_height: int) -> None: """Set the default tileset from a `.ttf` or `.otf` file. `path` is the file path for the font file. `tile_width` and `tile_height` are the desired size of the tiles in the new tileset. The font will be scaled to fit the given `tile_height` and `tile_width`. This function will only affect the `SDL2` and `OPENGL2` renderers. This function must be called before :any:`tcod.console_init_root`. Once the root console is setup you may call this funtion again to change the font. The tileset can be changed but the window will not be resized automatically. .. versionadded:: 9.2 """ if not os.path.exists(path): raise RuntimeError("File not found:\n\t%s" % (os.path.realpath(path),)) lib.TCOD_tileset_load_truetype_(path.encode(), tile_width, tile_height)
python
def set_truetype_font(path: str, tile_width: int, tile_height: int) -> None: """Set the default tileset from a `.ttf` or `.otf` file. `path` is the file path for the font file. `tile_width` and `tile_height` are the desired size of the tiles in the new tileset. The font will be scaled to fit the given `tile_height` and `tile_width`. This function will only affect the `SDL2` and `OPENGL2` renderers. This function must be called before :any:`tcod.console_init_root`. Once the root console is setup you may call this funtion again to change the font. The tileset can be changed but the window will not be resized automatically. .. versionadded:: 9.2 """ if not os.path.exists(path): raise RuntimeError("File not found:\n\t%s" % (os.path.realpath(path),)) lib.TCOD_tileset_load_truetype_(path.encode(), tile_width, tile_height)
[ "def", "set_truetype_font", "(", "path", ":", "str", ",", "tile_width", ":", "int", ",", "tile_height", ":", "int", ")", "->", "None", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "RuntimeError", "(", "\"File not found:\\n\\t%s\"", "%", "(", "os", ".", "path", ".", "realpath", "(", "path", ")", ",", ")", ")", "lib", ".", "TCOD_tileset_load_truetype_", "(", "path", ".", "encode", "(", ")", ",", "tile_width", ",", "tile_height", ")" ]
Set the default tileset from a `.ttf` or `.otf` file. `path` is the file path for the font file. `tile_width` and `tile_height` are the desired size of the tiles in the new tileset. The font will be scaled to fit the given `tile_height` and `tile_width`. This function will only affect the `SDL2` and `OPENGL2` renderers. This function must be called before :any:`tcod.console_init_root`. Once the root console is setup you may call this funtion again to change the font. The tileset can be changed but the window will not be resized automatically. .. versionadded:: 9.2
[ "Set", "the", "default", "tileset", "from", "a", ".", "ttf", "or", ".", "otf", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/tileset.py#L137-L157
train
libtcod/python-tcod
tcod/tileset.py
Tileset.get_tile
def get_tile(self, codepoint: int) -> np.array: """Return a copy of a tile for the given codepoint. If the tile does not exist yet then a blank array will be returned. The tile will have a shape of (height, width, rgba) and a dtype of uint8. Note that most grey-scale tiles will only use the alpha channel and will usually have a solid white color channel. """ tile = np.zeros(self.tile_shape + (4,), dtype=np.uint8) lib.TCOD_tileset_get_tile_( self._tileset_p, codepoint, ffi.cast("struct TCOD_ColorRGBA*", tile.ctypes.data), ) return tile
python
def get_tile(self, codepoint: int) -> np.array: """Return a copy of a tile for the given codepoint. If the tile does not exist yet then a blank array will be returned. The tile will have a shape of (height, width, rgba) and a dtype of uint8. Note that most grey-scale tiles will only use the alpha channel and will usually have a solid white color channel. """ tile = np.zeros(self.tile_shape + (4,), dtype=np.uint8) lib.TCOD_tileset_get_tile_( self._tileset_p, codepoint, ffi.cast("struct TCOD_ColorRGBA*", tile.ctypes.data), ) return tile
[ "def", "get_tile", "(", "self", ",", "codepoint", ":", "int", ")", "->", "np", ".", "array", ":", "tile", "=", "np", ".", "zeros", "(", "self", ".", "tile_shape", "+", "(", "4", ",", ")", ",", "dtype", "=", "np", ".", "uint8", ")", "lib", ".", "TCOD_tileset_get_tile_", "(", "self", ".", "_tileset_p", ",", "codepoint", ",", "ffi", ".", "cast", "(", "\"struct TCOD_ColorRGBA*\"", ",", "tile", ".", "ctypes", ".", "data", ")", ",", ")", "return", "tile" ]
Return a copy of a tile for the given codepoint. If the tile does not exist yet then a blank array will be returned. The tile will have a shape of (height, width, rgba) and a dtype of uint8. Note that most grey-scale tiles will only use the alpha channel and will usually have a solid white color channel.
[ "Return", "a", "copy", "of", "a", "tile", "for", "the", "given", "codepoint", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/tileset.py#L55-L70
train
libtcod/python-tcod
tcod/tileset.py
Tileset.set_tile
def set_tile(self, codepoint: int, tile: np.array) -> None: """Upload a tile into this array. The tile can be in 32-bit color (height, width, rgba), or grey-scale (height, width). The tile should have a dtype of ``np.uint8``. This data may need to be sent to graphics card memory, this is a slow operation. """ tile = np.ascontiguousarray(tile, dtype=np.uint8) if tile.shape == self.tile_shape: full_tile = np.empty(self.tile_shape + (4,), dtype=np.uint8) full_tile[:, :, :3] = 255 full_tile[:, :, 3] = tile return self.set_tile(codepoint, full_tile) required = self.tile_shape + (4,) if tile.shape != required: raise ValueError( "Tile shape must be %r or %r, got %r." % (required, self.tile_shape, tile.shape) ) lib.TCOD_tileset_set_tile_( self._tileset_p, codepoint, ffi.cast("struct TCOD_ColorRGBA*", tile.ctypes.data), )
python
def set_tile(self, codepoint: int, tile: np.array) -> None: """Upload a tile into this array. The tile can be in 32-bit color (height, width, rgba), or grey-scale (height, width). The tile should have a dtype of ``np.uint8``. This data may need to be sent to graphics card memory, this is a slow operation. """ tile = np.ascontiguousarray(tile, dtype=np.uint8) if tile.shape == self.tile_shape: full_tile = np.empty(self.tile_shape + (4,), dtype=np.uint8) full_tile[:, :, :3] = 255 full_tile[:, :, 3] = tile return self.set_tile(codepoint, full_tile) required = self.tile_shape + (4,) if tile.shape != required: raise ValueError( "Tile shape must be %r or %r, got %r." % (required, self.tile_shape, tile.shape) ) lib.TCOD_tileset_set_tile_( self._tileset_p, codepoint, ffi.cast("struct TCOD_ColorRGBA*", tile.ctypes.data), )
[ "def", "set_tile", "(", "self", ",", "codepoint", ":", "int", ",", "tile", ":", "np", ".", "array", ")", "->", "None", ":", "tile", "=", "np", ".", "ascontiguousarray", "(", "tile", ",", "dtype", "=", "np", ".", "uint8", ")", "if", "tile", ".", "shape", "==", "self", ".", "tile_shape", ":", "full_tile", "=", "np", ".", "empty", "(", "self", ".", "tile_shape", "+", "(", "4", ",", ")", ",", "dtype", "=", "np", ".", "uint8", ")", "full_tile", "[", ":", ",", ":", ",", ":", "3", "]", "=", "255", "full_tile", "[", ":", ",", ":", ",", "3", "]", "=", "tile", "return", "self", ".", "set_tile", "(", "codepoint", ",", "full_tile", ")", "required", "=", "self", ".", "tile_shape", "+", "(", "4", ",", ")", "if", "tile", ".", "shape", "!=", "required", ":", "raise", "ValueError", "(", "\"Tile shape must be %r or %r, got %r.\"", "%", "(", "required", ",", "self", ".", "tile_shape", ",", "tile", ".", "shape", ")", ")", "lib", ".", "TCOD_tileset_set_tile_", "(", "self", ".", "_tileset_p", ",", "codepoint", ",", "ffi", ".", "cast", "(", "\"struct TCOD_ColorRGBA*\"", ",", "tile", ".", "ctypes", ".", "data", ")", ",", ")" ]
Upload a tile into this array. The tile can be in 32-bit color (height, width, rgba), or grey-scale (height, width). The tile should have a dtype of ``np.uint8``. This data may need to be sent to graphics card memory, this is a slow operation.
[ "Upload", "a", "tile", "into", "this", "array", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/tileset.py#L72-L97
train
libtcod/python-tcod
build_libtcod.py
fix_header
def fix_header(filepath): """Removes leading whitespace from a MacOS header file. This whitespace is causing issues with directives on some platforms. """ with open(filepath, "r+") as f: current = f.read() fixed = "\n".join(line.strip() for line in current.split("\n")) if current == fixed: return f.seek(0) f.truncate() f.write(fixed)
python
def fix_header(filepath): """Removes leading whitespace from a MacOS header file. This whitespace is causing issues with directives on some platforms. """ with open(filepath, "r+") as f: current = f.read() fixed = "\n".join(line.strip() for line in current.split("\n")) if current == fixed: return f.seek(0) f.truncate() f.write(fixed)
[ "def", "fix_header", "(", "filepath", ")", ":", "with", "open", "(", "filepath", ",", "\"r+\"", ")", "as", "f", ":", "current", "=", "f", ".", "read", "(", ")", "fixed", "=", "\"\\n\"", ".", "join", "(", "line", ".", "strip", "(", ")", "for", "line", "in", "current", ".", "split", "(", "\"\\n\"", ")", ")", "if", "current", "==", "fixed", ":", "return", "f", ".", "seek", "(", "0", ")", "f", ".", "truncate", "(", ")", "f", ".", "write", "(", "fixed", ")" ]
Removes leading whitespace from a MacOS header file. This whitespace is causing issues with directives on some platforms.
[ "Removes", "leading", "whitespace", "from", "a", "MacOS", "header", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/build_libtcod.py#L145-L157
train
libtcod/python-tcod
build_libtcod.py
find_sdl_attrs
def find_sdl_attrs(prefix: str) -> Iterator[Tuple[str, Any]]: """Return names and values from `tcod.lib`. `prefix` is used to filter out which names to copy. """ from tcod._libtcod import lib if prefix.startswith("SDL_"): name_starts_at = 4 elif prefix.startswith("SDL"): name_starts_at = 3 else: name_starts_at = 0 for attr in dir(lib): if attr.startswith(prefix): yield attr[name_starts_at:], getattr(lib, attr)
python
def find_sdl_attrs(prefix: str) -> Iterator[Tuple[str, Any]]: """Return names and values from `tcod.lib`. `prefix` is used to filter out which names to copy. """ from tcod._libtcod import lib if prefix.startswith("SDL_"): name_starts_at = 4 elif prefix.startswith("SDL"): name_starts_at = 3 else: name_starts_at = 0 for attr in dir(lib): if attr.startswith(prefix): yield attr[name_starts_at:], getattr(lib, attr)
[ "def", "find_sdl_attrs", "(", "prefix", ":", "str", ")", "->", "Iterator", "[", "Tuple", "[", "str", ",", "Any", "]", "]", ":", "from", "tcod", ".", "_libtcod", "import", "lib", "if", "prefix", ".", "startswith", "(", "\"SDL_\"", ")", ":", "name_starts_at", "=", "4", "elif", "prefix", ".", "startswith", "(", "\"SDL\"", ")", ":", "name_starts_at", "=", "3", "else", ":", "name_starts_at", "=", "0", "for", "attr", "in", "dir", "(", "lib", ")", ":", "if", "attr", ".", "startswith", "(", "prefix", ")", ":", "yield", "attr", "[", "name_starts_at", ":", "]", ",", "getattr", "(", "lib", ",", "attr", ")" ]
Return names and values from `tcod.lib`. `prefix` is used to filter out which names to copy.
[ "Return", "names", "and", "values", "from", "tcod", ".", "lib", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/build_libtcod.py#L357-L372
train
libtcod/python-tcod
build_libtcod.py
write_library_constants
def write_library_constants(): """Write libtcod constants into the tcod.constants module.""" from tcod._libtcod import lib, ffi import tcod.color with open("tcod/constants.py", "w") as f: all_names = [] f.write(CONSTANT_MODULE_HEADER) for name in dir(lib): value = getattr(lib, name) if name[:5] == "TCOD_": if name.isupper(): # const names f.write("%s = %r\n" % (name[5:], value)) all_names.append(name[5:]) elif name.startswith("FOV"): # fov const names f.write("%s = %r\n" % (name, value)) all_names.append(name) elif name[:6] == "TCODK_": # key name f.write("KEY_%s = %r\n" % (name[6:], value)) all_names.append("KEY_%s" % name[6:]) f.write("\n# --- colors ---\n") for name in dir(lib): if name[:5] != "TCOD_": continue value = getattr(lib, name) if not isinstance(value, ffi.CData): continue if ffi.typeof(value) != ffi.typeof("TCOD_color_t"): continue color = tcod.color.Color._new_from_cdata(value) f.write("%s = %r\n" % (name[5:], color)) all_names.append(name[5:]) all_names = ",\n ".join('"%s"' % name for name in all_names) f.write("\n__all__ = [\n %s,\n]\n" % (all_names,)) with open("tcod/event_constants.py", "w") as f: all_names = [] f.write(EVENT_CONSTANT_MODULE_HEADER) f.write("# --- SDL scancodes ---\n") f.write( "%s\n_REVERSE_SCANCODE_TABLE = %s\n" % parse_sdl_attrs("SDL_SCANCODE", all_names) ) f.write("\n# --- SDL keyboard symbols ---\n") f.write( "%s\n_REVERSE_SYM_TABLE = %s\n" % parse_sdl_attrs("SDLK", all_names) ) f.write("\n# --- SDL keyboard modifiers ---\n") f.write( "%s\n_REVERSE_MOD_TABLE = %s\n" % parse_sdl_attrs("KMOD", all_names) ) f.write("\n# --- SDL wheel ---\n") f.write( "%s\n_REVERSE_WHEEL_TABLE = %s\n" % parse_sdl_attrs("SDL_MOUSEWHEEL", all_names) ) all_names = ",\n ".join('"%s"' % name for name in all_names) f.write("\n__all__ = [\n %s,\n]\n" % (all_names,))
python
def write_library_constants(): """Write libtcod constants into the tcod.constants module.""" from tcod._libtcod import lib, ffi import tcod.color with open("tcod/constants.py", "w") as f: all_names = [] f.write(CONSTANT_MODULE_HEADER) for name in dir(lib): value = getattr(lib, name) if name[:5] == "TCOD_": if name.isupper(): # const names f.write("%s = %r\n" % (name[5:], value)) all_names.append(name[5:]) elif name.startswith("FOV"): # fov const names f.write("%s = %r\n" % (name, value)) all_names.append(name) elif name[:6] == "TCODK_": # key name f.write("KEY_%s = %r\n" % (name[6:], value)) all_names.append("KEY_%s" % name[6:]) f.write("\n# --- colors ---\n") for name in dir(lib): if name[:5] != "TCOD_": continue value = getattr(lib, name) if not isinstance(value, ffi.CData): continue if ffi.typeof(value) != ffi.typeof("TCOD_color_t"): continue color = tcod.color.Color._new_from_cdata(value) f.write("%s = %r\n" % (name[5:], color)) all_names.append(name[5:]) all_names = ",\n ".join('"%s"' % name for name in all_names) f.write("\n__all__ = [\n %s,\n]\n" % (all_names,)) with open("tcod/event_constants.py", "w") as f: all_names = [] f.write(EVENT_CONSTANT_MODULE_HEADER) f.write("# --- SDL scancodes ---\n") f.write( "%s\n_REVERSE_SCANCODE_TABLE = %s\n" % parse_sdl_attrs("SDL_SCANCODE", all_names) ) f.write("\n# --- SDL keyboard symbols ---\n") f.write( "%s\n_REVERSE_SYM_TABLE = %s\n" % parse_sdl_attrs("SDLK", all_names) ) f.write("\n# --- SDL keyboard modifiers ---\n") f.write( "%s\n_REVERSE_MOD_TABLE = %s\n" % parse_sdl_attrs("KMOD", all_names) ) f.write("\n# --- SDL wheel ---\n") f.write( "%s\n_REVERSE_WHEEL_TABLE = %s\n" % parse_sdl_attrs("SDL_MOUSEWHEEL", all_names) ) all_names = ",\n ".join('"%s"' % name for name in all_names) f.write("\n__all__ = [\n %s,\n]\n" % (all_names,))
[ "def", "write_library_constants", "(", ")", ":", "from", "tcod", ".", "_libtcod", "import", "lib", ",", "ffi", "import", "tcod", ".", "color", "with", "open", "(", "\"tcod/constants.py\"", ",", "\"w\"", ")", "as", "f", ":", "all_names", "=", "[", "]", "f", ".", "write", "(", "CONSTANT_MODULE_HEADER", ")", "for", "name", "in", "dir", "(", "lib", ")", ":", "value", "=", "getattr", "(", "lib", ",", "name", ")", "if", "name", "[", ":", "5", "]", "==", "\"TCOD_\"", ":", "if", "name", ".", "isupper", "(", ")", ":", "# const names", "f", ".", "write", "(", "\"%s = %r\\n\"", "%", "(", "name", "[", "5", ":", "]", ",", "value", ")", ")", "all_names", ".", "append", "(", "name", "[", "5", ":", "]", ")", "elif", "name", ".", "startswith", "(", "\"FOV\"", ")", ":", "# fov const names", "f", ".", "write", "(", "\"%s = %r\\n\"", "%", "(", "name", ",", "value", ")", ")", "all_names", ".", "append", "(", "name", ")", "elif", "name", "[", ":", "6", "]", "==", "\"TCODK_\"", ":", "# key name", "f", ".", "write", "(", "\"KEY_%s = %r\\n\"", "%", "(", "name", "[", "6", ":", "]", ",", "value", ")", ")", "all_names", ".", "append", "(", "\"KEY_%s\"", "%", "name", "[", "6", ":", "]", ")", "f", ".", "write", "(", "\"\\n# --- colors ---\\n\"", ")", "for", "name", "in", "dir", "(", "lib", ")", ":", "if", "name", "[", ":", "5", "]", "!=", "\"TCOD_\"", ":", "continue", "value", "=", "getattr", "(", "lib", ",", "name", ")", "if", "not", "isinstance", "(", "value", ",", "ffi", ".", "CData", ")", ":", "continue", "if", "ffi", ".", "typeof", "(", "value", ")", "!=", "ffi", ".", "typeof", "(", "\"TCOD_color_t\"", ")", ":", "continue", "color", "=", "tcod", ".", "color", ".", "Color", ".", "_new_from_cdata", "(", "value", ")", "f", ".", "write", "(", "\"%s = %r\\n\"", "%", "(", "name", "[", "5", ":", "]", ",", "color", ")", ")", "all_names", ".", "append", "(", "name", "[", "5", ":", "]", ")", "all_names", "=", "\",\\n \"", ".", "join", "(", "'\"%s\"'", "%", "name", "for", "name", "in", "all_names", ")", "f", ".", "write", "(", "\"\\n__all__ = [\\n %s,\\n]\\n\"", "%", "(", "all_names", ",", ")", ")", "with", "open", "(", "\"tcod/event_constants.py\"", ",", "\"w\"", ")", "as", "f", ":", "all_names", "=", "[", "]", "f", ".", "write", "(", "EVENT_CONSTANT_MODULE_HEADER", ")", "f", ".", "write", "(", "\"# --- SDL scancodes ---\\n\"", ")", "f", ".", "write", "(", "\"%s\\n_REVERSE_SCANCODE_TABLE = %s\\n\"", "%", "parse_sdl_attrs", "(", "\"SDL_SCANCODE\"", ",", "all_names", ")", ")", "f", ".", "write", "(", "\"\\n# --- SDL keyboard symbols ---\\n\"", ")", "f", ".", "write", "(", "\"%s\\n_REVERSE_SYM_TABLE = %s\\n\"", "%", "parse_sdl_attrs", "(", "\"SDLK\"", ",", "all_names", ")", ")", "f", ".", "write", "(", "\"\\n# --- SDL keyboard modifiers ---\\n\"", ")", "f", ".", "write", "(", "\"%s\\n_REVERSE_MOD_TABLE = %s\\n\"", "%", "parse_sdl_attrs", "(", "\"KMOD\"", ",", "all_names", ")", ")", "f", ".", "write", "(", "\"\\n# --- SDL wheel ---\\n\"", ")", "f", ".", "write", "(", "\"%s\\n_REVERSE_WHEEL_TABLE = %s\\n\"", "%", "parse_sdl_attrs", "(", "\"SDL_MOUSEWHEEL\"", ",", "all_names", ")", ")", "all_names", "=", "\",\\n \"", ".", "join", "(", "'\"%s\"'", "%", "name", "for", "name", "in", "all_names", ")", "f", ".", "write", "(", "\"\\n__all__ = [\\n %s,\\n]\\n\"", "%", "(", "all_names", ",", ")", ")" ]
Write libtcod constants into the tcod.constants module.
[ "Write", "libtcod", "constants", "into", "the", "tcod", ".", "constants", "module", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/build_libtcod.py#L394-L458
train
libtcod/python-tcod
build_libtcod.py
CustomPostParser.visit_EnumeratorList
def visit_EnumeratorList(self, node): """Replace enumerator expressions with '...' stubs.""" for type, enum in node.children(): if enum.value is None: pass elif isinstance(enum.value, (c_ast.BinaryOp, c_ast.UnaryOp)): enum.value = c_ast.Constant("int", "...") elif hasattr(enum.value, "type"): enum.value = c_ast.Constant(enum.value.type, "...")
python
def visit_EnumeratorList(self, node): """Replace enumerator expressions with '...' stubs.""" for type, enum in node.children(): if enum.value is None: pass elif isinstance(enum.value, (c_ast.BinaryOp, c_ast.UnaryOp)): enum.value = c_ast.Constant("int", "...") elif hasattr(enum.value, "type"): enum.value = c_ast.Constant(enum.value.type, "...")
[ "def", "visit_EnumeratorList", "(", "self", ",", "node", ")", ":", "for", "type", ",", "enum", "in", "node", ".", "children", "(", ")", ":", "if", "enum", ".", "value", "is", "None", ":", "pass", "elif", "isinstance", "(", "enum", ".", "value", ",", "(", "c_ast", ".", "BinaryOp", ",", "c_ast", ".", "UnaryOp", ")", ")", ":", "enum", ".", "value", "=", "c_ast", ".", "Constant", "(", "\"int\"", ",", "\"...\"", ")", "elif", "hasattr", "(", "enum", ".", "value", ",", "\"type\"", ")", ":", "enum", ".", "value", "=", "c_ast", ".", "Constant", "(", "enum", ".", "value", ".", "type", ",", "\"...\"", ")" ]
Replace enumerator expressions with '...' stubs.
[ "Replace", "enumerator", "expressions", "with", "...", "stubs", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/build_libtcod.py#L214-L222
train
libtcod/python-tcod
tcod/libtcodpy.py
bsp_new_with_size
def bsp_new_with_size(x: int, y: int, w: int, h: int) -> tcod.bsp.BSP: """Create a new BSP instance with the given rectangle. Args: x (int): Rectangle left coordinate. y (int): Rectangle top coordinate. w (int): Rectangle width. h (int): Rectangle height. Returns: BSP: A new BSP instance. .. deprecated:: 2.0 Call the :any:`BSP` class instead. """ return Bsp(x, y, w, h)
python
def bsp_new_with_size(x: int, y: int, w: int, h: int) -> tcod.bsp.BSP: """Create a new BSP instance with the given rectangle. Args: x (int): Rectangle left coordinate. y (int): Rectangle top coordinate. w (int): Rectangle width. h (int): Rectangle height. Returns: BSP: A new BSP instance. .. deprecated:: 2.0 Call the :any:`BSP` class instead. """ return Bsp(x, y, w, h)
[ "def", "bsp_new_with_size", "(", "x", ":", "int", ",", "y", ":", "int", ",", "w", ":", "int", ",", "h", ":", "int", ")", "->", "tcod", ".", "bsp", ".", "BSP", ":", "return", "Bsp", "(", "x", ",", "y", ",", "w", ",", "h", ")" ]
Create a new BSP instance with the given rectangle. Args: x (int): Rectangle left coordinate. y (int): Rectangle top coordinate. w (int): Rectangle width. h (int): Rectangle height. Returns: BSP: A new BSP instance. .. deprecated:: 2.0 Call the :any:`BSP` class instead.
[ "Create", "a", "new", "BSP", "instance", "with", "the", "given", "rectangle", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L533-L548
train
libtcod/python-tcod
tcod/libtcodpy.py
_bsp_traverse
def _bsp_traverse( node_iter: Iterable[tcod.bsp.BSP], callback: Callable[[tcod.bsp.BSP, Any], None], userData: Any, ) -> None: """pack callback into a handle for use with the callback _pycall_bsp_callback """ for node in node_iter: callback(node, userData)
python
def _bsp_traverse( node_iter: Iterable[tcod.bsp.BSP], callback: Callable[[tcod.bsp.BSP, Any], None], userData: Any, ) -> None: """pack callback into a handle for use with the callback _pycall_bsp_callback """ for node in node_iter: callback(node, userData)
[ "def", "_bsp_traverse", "(", "node_iter", ":", "Iterable", "[", "tcod", ".", "bsp", ".", "BSP", "]", ",", "callback", ":", "Callable", "[", "[", "tcod", ".", "bsp", ".", "BSP", ",", "Any", "]", ",", "None", "]", ",", "userData", ":", "Any", ",", ")", "->", "None", ":", "for", "node", "in", "node_iter", ":", "callback", "(", "node", ",", "userData", ")" ]
pack callback into a handle for use with the callback _pycall_bsp_callback
[ "pack", "callback", "into", "a", "handle", "for", "use", "with", "the", "callback", "_pycall_bsp_callback" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L649-L658
train
libtcod/python-tcod
tcod/libtcodpy.py
color_lerp
def color_lerp( c1: Tuple[int, int, int], c2: Tuple[int, int, int], a: float ) -> Color: """Return the linear interpolation between two colors. ``a`` is the interpolation value, with 0 returing ``c1``, 1 returning ``c2``, and 0.5 returing a color halfway between both. Args: c1 (Union[Tuple[int, int, int], Sequence[int]]): The first color. At a=0. c2 (Union[Tuple[int, int, int], Sequence[int]]): The second color. At a=1. a (float): The interpolation value, Returns: Color: The interpolated Color. """ return Color._new_from_cdata(lib.TCOD_color_lerp(c1, c2, a))
python
def color_lerp( c1: Tuple[int, int, int], c2: Tuple[int, int, int], a: float ) -> Color: """Return the linear interpolation between two colors. ``a`` is the interpolation value, with 0 returing ``c1``, 1 returning ``c2``, and 0.5 returing a color halfway between both. Args: c1 (Union[Tuple[int, int, int], Sequence[int]]): The first color. At a=0. c2 (Union[Tuple[int, int, int], Sequence[int]]): The second color. At a=1. a (float): The interpolation value, Returns: Color: The interpolated Color. """ return Color._new_from_cdata(lib.TCOD_color_lerp(c1, c2, a))
[ "def", "color_lerp", "(", "c1", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ",", "c2", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ",", "a", ":", "float", ")", "->", "Color", ":", "return", "Color", ".", "_new_from_cdata", "(", "lib", ".", "TCOD_color_lerp", "(", "c1", ",", "c2", ",", "a", ")", ")" ]
Return the linear interpolation between two colors. ``a`` is the interpolation value, with 0 returing ``c1``, 1 returning ``c2``, and 0.5 returing a color halfway between both. Args: c1 (Union[Tuple[int, int, int], Sequence[int]]): The first color. At a=0. c2 (Union[Tuple[int, int, int], Sequence[int]]): The second color. At a=1. a (float): The interpolation value, Returns: Color: The interpolated Color.
[ "Return", "the", "linear", "interpolation", "between", "two", "colors", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L762-L780
train
libtcod/python-tcod
tcod/libtcodpy.py
color_scale_HSV
def color_scale_HSV(c: Color, scoef: float, vcoef: float) -> None: """Scale a color's saturation and value. Does not return a new Color. ``c`` is modified inplace. Args: c (Union[Color, List[int]]): A Color instance, or an [r, g, b] list. scoef (float): Saturation multiplier, from 0 to 1. Use 1 to keep current saturation. vcoef (float): Value multiplier, from 0 to 1. Use 1 to keep current value. """ color_p = ffi.new("TCOD_color_t*") color_p.r, color_p.g, color_p.b = c.r, c.g, c.b lib.TCOD_color_scale_HSV(color_p, scoef, vcoef) c[:] = color_p.r, color_p.g, color_p.b
python
def color_scale_HSV(c: Color, scoef: float, vcoef: float) -> None: """Scale a color's saturation and value. Does not return a new Color. ``c`` is modified inplace. Args: c (Union[Color, List[int]]): A Color instance, or an [r, g, b] list. scoef (float): Saturation multiplier, from 0 to 1. Use 1 to keep current saturation. vcoef (float): Value multiplier, from 0 to 1. Use 1 to keep current value. """ color_p = ffi.new("TCOD_color_t*") color_p.r, color_p.g, color_p.b = c.r, c.g, c.b lib.TCOD_color_scale_HSV(color_p, scoef, vcoef) c[:] = color_p.r, color_p.g, color_p.b
[ "def", "color_scale_HSV", "(", "c", ":", "Color", ",", "scoef", ":", "float", ",", "vcoef", ":", "float", ")", "->", "None", ":", "color_p", "=", "ffi", ".", "new", "(", "\"TCOD_color_t*\"", ")", "color_p", ".", "r", ",", "color_p", ".", "g", ",", "color_p", ".", "b", "=", "c", ".", "r", ",", "c", ".", "g", ",", "c", ".", "b", "lib", ".", "TCOD_color_scale_HSV", "(", "color_p", ",", "scoef", ",", "vcoef", ")", "c", "[", ":", "]", "=", "color_p", ".", "r", ",", "color_p", ".", "g", ",", "color_p", ".", "b" ]
Scale a color's saturation and value. Does not return a new Color. ``c`` is modified inplace. Args: c (Union[Color, List[int]]): A Color instance, or an [r, g, b] list. scoef (float): Saturation multiplier, from 0 to 1. Use 1 to keep current saturation. vcoef (float): Value multiplier, from 0 to 1. Use 1 to keep current value.
[ "Scale", "a", "color", "s", "saturation", "and", "value", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L818-L833
train
libtcod/python-tcod
tcod/libtcodpy.py
color_gen_map
def color_gen_map( colors: Iterable[Tuple[int, int, int]], indexes: Iterable[int] ) -> List[Color]: """Return a smoothly defined scale of colors. If ``indexes`` is [0, 3, 9] for example, the first color from ``colors`` will be returned at 0, the 2nd will be at 3, and the 3rd will be at 9. All in-betweens will be filled with a gradient. Args: colors (Iterable[Union[Tuple[int, int, int], Sequence[int]]]): Array of colors to be sampled. indexes (Iterable[int]): A list of indexes. Returns: List[Color]: A list of Color instances. Example: >>> tcod.color_gen_map([(0, 0, 0), (255, 128, 0)], [0, 5]) [Color(0, 0, 0), Color(51, 25, 0), Color(102, 51, 0), \ Color(153, 76, 0), Color(204, 102, 0), Color(255, 128, 0)] """ ccolors = ffi.new("TCOD_color_t[]", colors) cindexes = ffi.new("int[]", indexes) cres = ffi.new("TCOD_color_t[]", max(indexes) + 1) lib.TCOD_color_gen_map(cres, len(ccolors), ccolors, cindexes) return [Color._new_from_cdata(cdata) for cdata in cres]
python
def color_gen_map( colors: Iterable[Tuple[int, int, int]], indexes: Iterable[int] ) -> List[Color]: """Return a smoothly defined scale of colors. If ``indexes`` is [0, 3, 9] for example, the first color from ``colors`` will be returned at 0, the 2nd will be at 3, and the 3rd will be at 9. All in-betweens will be filled with a gradient. Args: colors (Iterable[Union[Tuple[int, int, int], Sequence[int]]]): Array of colors to be sampled. indexes (Iterable[int]): A list of indexes. Returns: List[Color]: A list of Color instances. Example: >>> tcod.color_gen_map([(0, 0, 0), (255, 128, 0)], [0, 5]) [Color(0, 0, 0), Color(51, 25, 0), Color(102, 51, 0), \ Color(153, 76, 0), Color(204, 102, 0), Color(255, 128, 0)] """ ccolors = ffi.new("TCOD_color_t[]", colors) cindexes = ffi.new("int[]", indexes) cres = ffi.new("TCOD_color_t[]", max(indexes) + 1) lib.TCOD_color_gen_map(cres, len(ccolors), ccolors, cindexes) return [Color._new_from_cdata(cdata) for cdata in cres]
[ "def", "color_gen_map", "(", "colors", ":", "Iterable", "[", "Tuple", "[", "int", ",", "int", ",", "int", "]", "]", ",", "indexes", ":", "Iterable", "[", "int", "]", ")", "->", "List", "[", "Color", "]", ":", "ccolors", "=", "ffi", ".", "new", "(", "\"TCOD_color_t[]\"", ",", "colors", ")", "cindexes", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "indexes", ")", "cres", "=", "ffi", ".", "new", "(", "\"TCOD_color_t[]\"", ",", "max", "(", "indexes", ")", "+", "1", ")", "lib", ".", "TCOD_color_gen_map", "(", "cres", ",", "len", "(", "ccolors", ")", ",", "ccolors", ",", "cindexes", ")", "return", "[", "Color", ".", "_new_from_cdata", "(", "cdata", ")", "for", "cdata", "in", "cres", "]" ]
Return a smoothly defined scale of colors. If ``indexes`` is [0, 3, 9] for example, the first color from ``colors`` will be returned at 0, the 2nd will be at 3, and the 3rd will be at 9. All in-betweens will be filled with a gradient. Args: colors (Iterable[Union[Tuple[int, int, int], Sequence[int]]]): Array of colors to be sampled. indexes (Iterable[int]): A list of indexes. Returns: List[Color]: A list of Color instances. Example: >>> tcod.color_gen_map([(0, 0, 0), (255, 128, 0)], [0, 5]) [Color(0, 0, 0), Color(51, 25, 0), Color(102, 51, 0), \ Color(153, 76, 0), Color(204, 102, 0), Color(255, 128, 0)]
[ "Return", "a", "smoothly", "defined", "scale", "of", "colors", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L837-L863
train
libtcod/python-tcod
tcod/libtcodpy.py
console_init_root
def console_init_root( w: int, h: int, title: Optional[str] = None, fullscreen: bool = False, renderer: Optional[int] = None, order: str = "C", ) -> tcod.console.Console: """Set up the primary display and return the root console. `w` and `h` are the columns and rows of the new window (in tiles.) `title` is an optional string to display on the windows title bar. `fullscreen` determines if the window will start in fullscreen. Fullscreen mode is unreliable unless the renderer is set to `tcod.RENDERER_SDL2` or `tcod.RENDERER_OPENGL2`. `renderer` is the rendering back-end that libtcod will use. If you don't know which to pick, then use `tcod.RENDERER_SDL2`. Options are: * `tcod.RENDERER_SDL`: A deprecated software/SDL2 renderer. * `tcod.RENDERER_OPENGL`: A deprecated SDL2/OpenGL1 renderer. * `tcod.RENDERER_GLSL`: A deprecated SDL2/OpenGL2 renderer. * `tcod.RENDERER_SDL2`: The recommended SDL2 renderer. Rendering is decided by SDL2 and can be changed by using an SDL2 hint. * `tcod.RENDERER_OPENGL2`: An SDL2/OPENGL2 renderer. Usually faster than regular SDL2. Requires OpenGL 2.0 Core. `order` will affect how the array attributes of the returned root console are indexed. `order='C'` is the default, but `order='F'` is recommended. .. versionchanged:: 4.3 Added `order` parameter. `title` parameter is now optional. .. versionchanged:: 8.0 The default `renderer` is now automatic instead of always being `RENDERER_SDL`. """ if title is None: # Use the scripts filename as the title. title = os.path.basename(sys.argv[0]) if renderer is None: warnings.warn( "A renderer should be given, see the online documentation.", DeprecationWarning, stacklevel=2, ) renderer = tcod.constants.RENDERER_SDL elif renderer in ( tcod.constants.RENDERER_SDL, tcod.constants.RENDERER_OPENGL, tcod.constants.RENDERER_GLSL, ): warnings.warn( "The SDL, OPENGL, and GLSL renderers are deprecated.", DeprecationWarning, stacklevel=2, ) lib.TCOD_console_init_root(w, h, _bytes(title), fullscreen, renderer) console = tcod.console.Console._get_root(order) console.clear() return console
python
def console_init_root( w: int, h: int, title: Optional[str] = None, fullscreen: bool = False, renderer: Optional[int] = None, order: str = "C", ) -> tcod.console.Console: """Set up the primary display and return the root console. `w` and `h` are the columns and rows of the new window (in tiles.) `title` is an optional string to display on the windows title bar. `fullscreen` determines if the window will start in fullscreen. Fullscreen mode is unreliable unless the renderer is set to `tcod.RENDERER_SDL2` or `tcod.RENDERER_OPENGL2`. `renderer` is the rendering back-end that libtcod will use. If you don't know which to pick, then use `tcod.RENDERER_SDL2`. Options are: * `tcod.RENDERER_SDL`: A deprecated software/SDL2 renderer. * `tcod.RENDERER_OPENGL`: A deprecated SDL2/OpenGL1 renderer. * `tcod.RENDERER_GLSL`: A deprecated SDL2/OpenGL2 renderer. * `tcod.RENDERER_SDL2`: The recommended SDL2 renderer. Rendering is decided by SDL2 and can be changed by using an SDL2 hint. * `tcod.RENDERER_OPENGL2`: An SDL2/OPENGL2 renderer. Usually faster than regular SDL2. Requires OpenGL 2.0 Core. `order` will affect how the array attributes of the returned root console are indexed. `order='C'` is the default, but `order='F'` is recommended. .. versionchanged:: 4.3 Added `order` parameter. `title` parameter is now optional. .. versionchanged:: 8.0 The default `renderer` is now automatic instead of always being `RENDERER_SDL`. """ if title is None: # Use the scripts filename as the title. title = os.path.basename(sys.argv[0]) if renderer is None: warnings.warn( "A renderer should be given, see the online documentation.", DeprecationWarning, stacklevel=2, ) renderer = tcod.constants.RENDERER_SDL elif renderer in ( tcod.constants.RENDERER_SDL, tcod.constants.RENDERER_OPENGL, tcod.constants.RENDERER_GLSL, ): warnings.warn( "The SDL, OPENGL, and GLSL renderers are deprecated.", DeprecationWarning, stacklevel=2, ) lib.TCOD_console_init_root(w, h, _bytes(title), fullscreen, renderer) console = tcod.console.Console._get_root(order) console.clear() return console
[ "def", "console_init_root", "(", "w", ":", "int", ",", "h", ":", "int", ",", "title", ":", "Optional", "[", "str", "]", "=", "None", ",", "fullscreen", ":", "bool", "=", "False", ",", "renderer", ":", "Optional", "[", "int", "]", "=", "None", ",", "order", ":", "str", "=", "\"C\"", ",", ")", "->", "tcod", ".", "console", ".", "Console", ":", "if", "title", "is", "None", ":", "# Use the scripts filename as the title.", "title", "=", "os", ".", "path", ".", "basename", "(", "sys", ".", "argv", "[", "0", "]", ")", "if", "renderer", "is", "None", ":", "warnings", ".", "warn", "(", "\"A renderer should be given, see the online documentation.\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ",", ")", "renderer", "=", "tcod", ".", "constants", ".", "RENDERER_SDL", "elif", "renderer", "in", "(", "tcod", ".", "constants", ".", "RENDERER_SDL", ",", "tcod", ".", "constants", ".", "RENDERER_OPENGL", ",", "tcod", ".", "constants", ".", "RENDERER_GLSL", ",", ")", ":", "warnings", ".", "warn", "(", "\"The SDL, OPENGL, and GLSL renderers are deprecated.\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ",", ")", "lib", ".", "TCOD_console_init_root", "(", "w", ",", "h", ",", "_bytes", "(", "title", ")", ",", "fullscreen", ",", "renderer", ")", "console", "=", "tcod", ".", "console", ".", "Console", ".", "_get_root", "(", "order", ")", "console", ".", "clear", "(", ")", "return", "console" ]
Set up the primary display and return the root console. `w` and `h` are the columns and rows of the new window (in tiles.) `title` is an optional string to display on the windows title bar. `fullscreen` determines if the window will start in fullscreen. Fullscreen mode is unreliable unless the renderer is set to `tcod.RENDERER_SDL2` or `tcod.RENDERER_OPENGL2`. `renderer` is the rendering back-end that libtcod will use. If you don't know which to pick, then use `tcod.RENDERER_SDL2`. Options are: * `tcod.RENDERER_SDL`: A deprecated software/SDL2 renderer. * `tcod.RENDERER_OPENGL`: A deprecated SDL2/OpenGL1 renderer. * `tcod.RENDERER_GLSL`: A deprecated SDL2/OpenGL2 renderer. * `tcod.RENDERER_SDL2`: The recommended SDL2 renderer. Rendering is decided by SDL2 and can be changed by using an SDL2 hint. * `tcod.RENDERER_OPENGL2`: An SDL2/OPENGL2 renderer. Usually faster than regular SDL2. Requires OpenGL 2.0 Core. `order` will affect how the array attributes of the returned root console are indexed. `order='C'` is the default, but `order='F'` is recommended. .. versionchanged:: 4.3 Added `order` parameter. `title` parameter is now optional. .. versionchanged:: 8.0 The default `renderer` is now automatic instead of always being `RENDERER_SDL`.
[ "Set", "up", "the", "primary", "display", "and", "return", "the", "root", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L866-L935
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_custom_font
def console_set_custom_font( fontFile: AnyStr, flags: int = FONT_LAYOUT_ASCII_INCOL, nb_char_horiz: int = 0, nb_char_vertic: int = 0, ) -> None: """Load the custom font file at `fontFile`. Call this before function before calling :any:`tcod.console_init_root`. Flags can be a mix of the following: * tcod.FONT_LAYOUT_ASCII_INCOL: Decode tileset raw in column-major order. * tcod.FONT_LAYOUT_ASCII_INROW: Decode tileset raw in row-major order. * tcod.FONT_TYPE_GREYSCALE: Force tileset to be read as greyscale. * tcod.FONT_TYPE_GRAYSCALE * tcod.FONT_LAYOUT_TCOD: Unique layout used by libtcod. * tcod.FONT_LAYOUT_CP437: Decode a row-major Code Page 437 tileset into Unicode. `nb_char_horiz` and `nb_char_vertic` are the columns and rows of the font file respectfully. """ if not os.path.exists(fontFile): raise RuntimeError( "File not found:\n\t%s" % (os.path.realpath(fontFile),) ) lib.TCOD_console_set_custom_font( _bytes(fontFile), flags, nb_char_horiz, nb_char_vertic )
python
def console_set_custom_font( fontFile: AnyStr, flags: int = FONT_LAYOUT_ASCII_INCOL, nb_char_horiz: int = 0, nb_char_vertic: int = 0, ) -> None: """Load the custom font file at `fontFile`. Call this before function before calling :any:`tcod.console_init_root`. Flags can be a mix of the following: * tcod.FONT_LAYOUT_ASCII_INCOL: Decode tileset raw in column-major order. * tcod.FONT_LAYOUT_ASCII_INROW: Decode tileset raw in row-major order. * tcod.FONT_TYPE_GREYSCALE: Force tileset to be read as greyscale. * tcod.FONT_TYPE_GRAYSCALE * tcod.FONT_LAYOUT_TCOD: Unique layout used by libtcod. * tcod.FONT_LAYOUT_CP437: Decode a row-major Code Page 437 tileset into Unicode. `nb_char_horiz` and `nb_char_vertic` are the columns and rows of the font file respectfully. """ if not os.path.exists(fontFile): raise RuntimeError( "File not found:\n\t%s" % (os.path.realpath(fontFile),) ) lib.TCOD_console_set_custom_font( _bytes(fontFile), flags, nb_char_horiz, nb_char_vertic )
[ "def", "console_set_custom_font", "(", "fontFile", ":", "AnyStr", ",", "flags", ":", "int", "=", "FONT_LAYOUT_ASCII_INCOL", ",", "nb_char_horiz", ":", "int", "=", "0", ",", "nb_char_vertic", ":", "int", "=", "0", ",", ")", "->", "None", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "fontFile", ")", ":", "raise", "RuntimeError", "(", "\"File not found:\\n\\t%s\"", "%", "(", "os", ".", "path", ".", "realpath", "(", "fontFile", ")", ",", ")", ")", "lib", ".", "TCOD_console_set_custom_font", "(", "_bytes", "(", "fontFile", ")", ",", "flags", ",", "nb_char_horiz", ",", "nb_char_vertic", ")" ]
Load the custom font file at `fontFile`. Call this before function before calling :any:`tcod.console_init_root`. Flags can be a mix of the following: * tcod.FONT_LAYOUT_ASCII_INCOL: Decode tileset raw in column-major order. * tcod.FONT_LAYOUT_ASCII_INROW: Decode tileset raw in row-major order. * tcod.FONT_TYPE_GREYSCALE: Force tileset to be read as greyscale. * tcod.FONT_TYPE_GRAYSCALE * tcod.FONT_LAYOUT_TCOD: Unique layout used by libtcod. * tcod.FONT_LAYOUT_CP437: Decode a row-major Code Page 437 tileset into Unicode. `nb_char_horiz` and `nb_char_vertic` are the columns and rows of the font file respectfully.
[ "Load", "the", "custom", "font", "file", "at", "fontFile", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L938-L971
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_width
def console_get_width(con: tcod.console.Console) -> int: """Return the width of a console. Args: con (Console): Any Console instance. Returns: int: The width of a Console. .. deprecated:: 2.0 Use `Console.width` instead. """ return int(lib.TCOD_console_get_width(_console(con)))
python
def console_get_width(con: tcod.console.Console) -> int: """Return the width of a console. Args: con (Console): Any Console instance. Returns: int: The width of a Console. .. deprecated:: 2.0 Use `Console.width` instead. """ return int(lib.TCOD_console_get_width(_console(con)))
[ "def", "console_get_width", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_console_get_width", "(", "_console", "(", "con", ")", ")", ")" ]
Return the width of a console. Args: con (Console): Any Console instance. Returns: int: The width of a Console. .. deprecated:: 2.0 Use `Console.width` instead.
[ "Return", "the", "width", "of", "a", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L975-L987
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_height
def console_get_height(con: tcod.console.Console) -> int: """Return the height of a console. Args: con (Console): Any Console instance. Returns: int: The height of a Console. .. deprecated:: 2.0 Use `Console.height` instead. """ return int(lib.TCOD_console_get_height(_console(con)))
python
def console_get_height(con: tcod.console.Console) -> int: """Return the height of a console. Args: con (Console): Any Console instance. Returns: int: The height of a Console. .. deprecated:: 2.0 Use `Console.height` instead. """ return int(lib.TCOD_console_get_height(_console(con)))
[ "def", "console_get_height", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_console_get_height", "(", "_console", "(", "con", ")", ")", ")" ]
Return the height of a console. Args: con (Console): Any Console instance. Returns: int: The height of a Console. .. deprecated:: 2.0 Use `Console.height` instead.
[ "Return", "the", "height", "of", "a", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L991-L1003
train
libtcod/python-tcod
tcod/libtcodpy.py
console_map_ascii_code_to_font
def console_map_ascii_code_to_font( asciiCode: int, fontCharX: int, fontCharY: int ) -> None: """Set a character code to new coordinates on the tile-set. `asciiCode` must be within the bounds created during the initialization of the loaded tile-set. For example, you can't use 255 here unless you have a 256 tile tile-set loaded. This applies to all functions in this group. Args: asciiCode (int): The character code to change. fontCharX (int): The X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The Y tile coordinate on the loaded tileset. 0 is the topmost tile. """ lib.TCOD_console_map_ascii_code_to_font( _int(asciiCode), fontCharX, fontCharY )
python
def console_map_ascii_code_to_font( asciiCode: int, fontCharX: int, fontCharY: int ) -> None: """Set a character code to new coordinates on the tile-set. `asciiCode` must be within the bounds created during the initialization of the loaded tile-set. For example, you can't use 255 here unless you have a 256 tile tile-set loaded. This applies to all functions in this group. Args: asciiCode (int): The character code to change. fontCharX (int): The X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The Y tile coordinate on the loaded tileset. 0 is the topmost tile. """ lib.TCOD_console_map_ascii_code_to_font( _int(asciiCode), fontCharX, fontCharY )
[ "def", "console_map_ascii_code_to_font", "(", "asciiCode", ":", "int", ",", "fontCharX", ":", "int", ",", "fontCharY", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_console_map_ascii_code_to_font", "(", "_int", "(", "asciiCode", ")", ",", "fontCharX", ",", "fontCharY", ")" ]
Set a character code to new coordinates on the tile-set. `asciiCode` must be within the bounds created during the initialization of the loaded tile-set. For example, you can't use 255 here unless you have a 256 tile tile-set loaded. This applies to all functions in this group. Args: asciiCode (int): The character code to change. fontCharX (int): The X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The Y tile coordinate on the loaded tileset. 0 is the topmost tile.
[ "Set", "a", "character", "code", "to", "new", "coordinates", "on", "the", "tile", "-", "set", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1007-L1025
train
libtcod/python-tcod
tcod/libtcodpy.py
console_map_ascii_codes_to_font
def console_map_ascii_codes_to_font( firstAsciiCode: int, nbCodes: int, fontCharX: int, fontCharY: int ) -> None: """Remap a contiguous set of codes to a contiguous set of tiles. Both the tile-set and character codes must be contiguous to use this function. If this is not the case you may want to use :any:`console_map_ascii_code_to_font`. Args: firstAsciiCode (int): The starting character code. nbCodes (int): The length of the contiguous set. fontCharX (int): The starting X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The starting Y tile coordinate on the loaded tileset. 0 is the topmost tile. """ lib.TCOD_console_map_ascii_codes_to_font( _int(firstAsciiCode), nbCodes, fontCharX, fontCharY )
python
def console_map_ascii_codes_to_font( firstAsciiCode: int, nbCodes: int, fontCharX: int, fontCharY: int ) -> None: """Remap a contiguous set of codes to a contiguous set of tiles. Both the tile-set and character codes must be contiguous to use this function. If this is not the case you may want to use :any:`console_map_ascii_code_to_font`. Args: firstAsciiCode (int): The starting character code. nbCodes (int): The length of the contiguous set. fontCharX (int): The starting X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The starting Y tile coordinate on the loaded tileset. 0 is the topmost tile. """ lib.TCOD_console_map_ascii_codes_to_font( _int(firstAsciiCode), nbCodes, fontCharX, fontCharY )
[ "def", "console_map_ascii_codes_to_font", "(", "firstAsciiCode", ":", "int", ",", "nbCodes", ":", "int", ",", "fontCharX", ":", "int", ",", "fontCharY", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_console_map_ascii_codes_to_font", "(", "_int", "(", "firstAsciiCode", ")", ",", "nbCodes", ",", "fontCharX", ",", "fontCharY", ")" ]
Remap a contiguous set of codes to a contiguous set of tiles. Both the tile-set and character codes must be contiguous to use this function. If this is not the case you may want to use :any:`console_map_ascii_code_to_font`. Args: firstAsciiCode (int): The starting character code. nbCodes (int): The length of the contiguous set. fontCharX (int): The starting X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The starting Y tile coordinate on the loaded tileset. 0 is the topmost tile.
[ "Remap", "a", "contiguous", "set", "of", "codes", "to", "a", "contiguous", "set", "of", "tiles", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1029-L1049
train
libtcod/python-tcod
tcod/libtcodpy.py
console_map_string_to_font
def console_map_string_to_font(s: str, fontCharX: int, fontCharY: int) -> None: """Remap a string of codes to a contiguous set of tiles. Args: s (AnyStr): A string of character codes to map to new values. The null character `'\\x00'` will prematurely end this function. fontCharX (int): The starting X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The starting Y tile coordinate on the loaded tileset. 0 is the topmost tile. """ lib.TCOD_console_map_string_to_font_utf(_unicode(s), fontCharX, fontCharY)
python
def console_map_string_to_font(s: str, fontCharX: int, fontCharY: int) -> None: """Remap a string of codes to a contiguous set of tiles. Args: s (AnyStr): A string of character codes to map to new values. The null character `'\\x00'` will prematurely end this function. fontCharX (int): The starting X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The starting Y tile coordinate on the loaded tileset. 0 is the topmost tile. """ lib.TCOD_console_map_string_to_font_utf(_unicode(s), fontCharX, fontCharY)
[ "def", "console_map_string_to_font", "(", "s", ":", "str", ",", "fontCharX", ":", "int", ",", "fontCharY", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_console_map_string_to_font_utf", "(", "_unicode", "(", "s", ")", ",", "fontCharX", ",", "fontCharY", ")" ]
Remap a string of codes to a contiguous set of tiles. Args: s (AnyStr): A string of character codes to map to new values. The null character `'\\x00'` will prematurely end this function. fontCharX (int): The starting X tile coordinate on the loaded tileset. 0 is the leftmost tile. fontCharY (int): The starting Y tile coordinate on the loaded tileset. 0 is the topmost tile.
[ "Remap", "a", "string", "of", "codes", "to", "a", "contiguous", "set", "of", "tiles", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1053-L1065
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_default_background
def console_set_default_background( con: tcod.console.Console, col: Tuple[int, int, int] ) -> None: """Change the default background color for a console. Args: con (Console): Any Console instance. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.5 Use :any:`Console.default_bg` instead. """ lib.TCOD_console_set_default_background(_console(con), col)
python
def console_set_default_background( con: tcod.console.Console, col: Tuple[int, int, int] ) -> None: """Change the default background color for a console. Args: con (Console): Any Console instance. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.5 Use :any:`Console.default_bg` instead. """ lib.TCOD_console_set_default_background(_console(con), col)
[ "def", "console_set_default_background", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "col", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_default_background", "(", "_console", "(", "con", ")", ",", "col", ")" ]
Change the default background color for a console. Args: con (Console): Any Console instance. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.5 Use :any:`Console.default_bg` instead.
[ "Change", "the", "default", "background", "color", "for", "a", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1138-L1151
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_default_foreground
def console_set_default_foreground( con: tcod.console.Console, col: Tuple[int, int, int] ) -> None: """Change the default foreground color for a console. Args: con (Console): Any Console instance. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.5 Use :any:`Console.default_fg` instead. """ lib.TCOD_console_set_default_foreground(_console(con), col)
python
def console_set_default_foreground( con: tcod.console.Console, col: Tuple[int, int, int] ) -> None: """Change the default foreground color for a console. Args: con (Console): Any Console instance. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.5 Use :any:`Console.default_fg` instead. """ lib.TCOD_console_set_default_foreground(_console(con), col)
[ "def", "console_set_default_foreground", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "col", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_default_foreground", "(", "_console", "(", "con", ")", ",", "col", ")" ]
Change the default foreground color for a console. Args: con (Console): Any Console instance. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.5 Use :any:`Console.default_fg` instead.
[ "Change", "the", "default", "foreground", "color", "for", "a", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1155-L1168
train
libtcod/python-tcod
tcod/libtcodpy.py
console_put_char_ex
def console_put_char_ex( con: tcod.console.Console, x: int, y: int, c: Union[int, str], fore: Tuple[int, int, int], back: Tuple[int, int, int], ) -> None: """Draw the character c at x,y using the colors fore and back. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. c (Union[int, AnyStr]): Character to draw, can be an integer or string. fore (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. back (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_console_put_char_ex(_console(con), x, y, _int(c), fore, back)
python
def console_put_char_ex( con: tcod.console.Console, x: int, y: int, c: Union[int, str], fore: Tuple[int, int, int], back: Tuple[int, int, int], ) -> None: """Draw the character c at x,y using the colors fore and back. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. c (Union[int, AnyStr]): Character to draw, can be an integer or string. fore (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. back (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_console_put_char_ex(_console(con), x, y, _int(c), fore, back)
[ "def", "console_put_char_ex", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "c", ":", "Union", "[", "int", ",", "str", "]", ",", "fore", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ",", "back", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ",", ")", "->", "None", ":", "lib", ".", "TCOD_console_put_char_ex", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "_int", "(", "c", ")", ",", "fore", ",", "back", ")" ]
Draw the character c at x,y using the colors fore and back. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. c (Union[int, AnyStr]): Character to draw, can be an integer or string. fore (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. back (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance.
[ "Draw", "the", "character", "c", "at", "x", "y", "using", "the", "colors", "fore", "and", "back", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1209-L1229
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_char_background
def console_set_char_background( con: tcod.console.Console, x: int, y: int, col: Tuple[int, int, int], flag: int = BKGND_SET, ) -> None: """Change the background color of x,y to col using a blend mode. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. flag (int): Blending mode to use, defaults to BKGND_SET. """ lib.TCOD_console_set_char_background(_console(con), x, y, col, flag)
python
def console_set_char_background( con: tcod.console.Console, x: int, y: int, col: Tuple[int, int, int], flag: int = BKGND_SET, ) -> None: """Change the background color of x,y to col using a blend mode. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. flag (int): Blending mode to use, defaults to BKGND_SET. """ lib.TCOD_console_set_char_background(_console(con), x, y, col, flag)
[ "def", "console_set_char_background", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "col", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ",", "flag", ":", "int", "=", "BKGND_SET", ",", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_char_background", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "col", ",", "flag", ")" ]
Change the background color of x,y to col using a blend mode. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. flag (int): Blending mode to use, defaults to BKGND_SET.
[ "Change", "the", "background", "color", "of", "x", "y", "to", "col", "using", "a", "blend", "mode", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1233-L1250
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_char_foreground
def console_set_char_foreground( con: tcod.console.Console, x: int, y: int, col: Tuple[int, int, int] ) -> None: """Change the foreground color of x,y to col. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.fg`. """ lib.TCOD_console_set_char_foreground(_console(con), x, y, col)
python
def console_set_char_foreground( con: tcod.console.Console, x: int, y: int, col: Tuple[int, int, int] ) -> None: """Change the foreground color of x,y to col. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.fg`. """ lib.TCOD_console_set_char_foreground(_console(con), x, y, col)
[ "def", "console_set_char_foreground", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "col", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_char_foreground", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "col", ")" ]
Change the foreground color of x,y to col. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. col (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.fg`.
[ "Change", "the", "foreground", "color", "of", "x", "y", "to", "col", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1254-L1270
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_char
def console_set_char( con: tcod.console.Console, x: int, y: int, c: Union[int, str] ) -> None: """Change the character at x,y to c, keeping the current colors. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. c (Union[int, AnyStr]): Character to draw, can be an integer or string. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.ch`. """ lib.TCOD_console_set_char(_console(con), x, y, _int(c))
python
def console_set_char( con: tcod.console.Console, x: int, y: int, c: Union[int, str] ) -> None: """Change the character at x,y to c, keeping the current colors. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. c (Union[int, AnyStr]): Character to draw, can be an integer or string. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.ch`. """ lib.TCOD_console_set_char(_console(con), x, y, _int(c))
[ "def", "console_set_char", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "c", ":", "Union", "[", "int", ",", "str", "]", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_char", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "_int", "(", "c", ")", ")" ]
Change the character at x,y to c, keeping the current colors. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. c (Union[int, AnyStr]): Character to draw, can be an integer or string. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.ch`.
[ "Change", "the", "character", "at", "x", "y", "to", "c", "keeping", "the", "current", "colors", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1274-L1289
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_background_flag
def console_set_background_flag(con: tcod.console.Console, flag: int) -> None: """Change the default blend mode for this console. Args: con (Console): Any Console instance. flag (int): Blend mode to use by default. .. deprecated:: 8.5 Set :any:`Console.default_bg_blend` instead. """ lib.TCOD_console_set_background_flag(_console(con), flag)
python
def console_set_background_flag(con: tcod.console.Console, flag: int) -> None: """Change the default blend mode for this console. Args: con (Console): Any Console instance. flag (int): Blend mode to use by default. .. deprecated:: 8.5 Set :any:`Console.default_bg_blend` instead. """ lib.TCOD_console_set_background_flag(_console(con), flag)
[ "def", "console_set_background_flag", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "flag", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_background_flag", "(", "_console", "(", "con", ")", ",", "flag", ")" ]
Change the default blend mode for this console. Args: con (Console): Any Console instance. flag (int): Blend mode to use by default. .. deprecated:: 8.5 Set :any:`Console.default_bg_blend` instead.
[ "Change", "the", "default", "blend", "mode", "for", "this", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1293-L1303
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_background_flag
def console_get_background_flag(con: tcod.console.Console) -> int: """Return this consoles current blend mode. Args: con (Console): Any Console instance. .. deprecated:: 8.5 Check :any:`Console.default_bg_blend` instead. """ return int(lib.TCOD_console_get_background_flag(_console(con)))
python
def console_get_background_flag(con: tcod.console.Console) -> int: """Return this consoles current blend mode. Args: con (Console): Any Console instance. .. deprecated:: 8.5 Check :any:`Console.default_bg_blend` instead. """ return int(lib.TCOD_console_get_background_flag(_console(con)))
[ "def", "console_get_background_flag", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_console_get_background_flag", "(", "_console", "(", "con", ")", ")", ")" ]
Return this consoles current blend mode. Args: con (Console): Any Console instance. .. deprecated:: 8.5 Check :any:`Console.default_bg_blend` instead.
[ "Return", "this", "consoles", "current", "blend", "mode", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1307-L1316
train
libtcod/python-tcod
tcod/libtcodpy.py
console_set_alignment
def console_set_alignment(con: tcod.console.Console, alignment: int) -> None: """Change this consoles current alignment mode. * tcod.LEFT * tcod.CENTER * tcod.RIGHT Args: con (Console): Any Console instance. alignment (int): .. deprecated:: 8.5 Set :any:`Console.default_alignment` instead. """ lib.TCOD_console_set_alignment(_console(con), alignment)
python
def console_set_alignment(con: tcod.console.Console, alignment: int) -> None: """Change this consoles current alignment mode. * tcod.LEFT * tcod.CENTER * tcod.RIGHT Args: con (Console): Any Console instance. alignment (int): .. deprecated:: 8.5 Set :any:`Console.default_alignment` instead. """ lib.TCOD_console_set_alignment(_console(con), alignment)
[ "def", "console_set_alignment", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "alignment", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_console_set_alignment", "(", "_console", "(", "con", ")", ",", "alignment", ")" ]
Change this consoles current alignment mode. * tcod.LEFT * tcod.CENTER * tcod.RIGHT Args: con (Console): Any Console instance. alignment (int): .. deprecated:: 8.5 Set :any:`Console.default_alignment` instead.
[ "Change", "this", "consoles", "current", "alignment", "mode", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1320-L1334
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_alignment
def console_get_alignment(con: tcod.console.Console) -> int: """Return this consoles current alignment mode. Args: con (Console): Any Console instance. .. deprecated:: 8.5 Check :any:`Console.default_alignment` instead. """ return int(lib.TCOD_console_get_alignment(_console(con)))
python
def console_get_alignment(con: tcod.console.Console) -> int: """Return this consoles current alignment mode. Args: con (Console): Any Console instance. .. deprecated:: 8.5 Check :any:`Console.default_alignment` instead. """ return int(lib.TCOD_console_get_alignment(_console(con)))
[ "def", "console_get_alignment", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_console_get_alignment", "(", "_console", "(", "con", ")", ")", ")" ]
Return this consoles current alignment mode. Args: con (Console): Any Console instance. .. deprecated:: 8.5 Check :any:`Console.default_alignment` instead.
[ "Return", "this", "consoles", "current", "alignment", "mode", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1338-L1347
train
libtcod/python-tcod
tcod/libtcodpy.py
console_print_ex
def console_print_ex( con: tcod.console.Console, x: int, y: int, flag: int, alignment: int, fmt: str, ) -> None: """Print a string on a console using a blend mode and alignment mode. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. .. deprecated:: 8.5 Use :any:`Console.print_` instead. """ lib.TCOD_console_printf_ex(_console(con), x, y, flag, alignment, _fmt(fmt))
python
def console_print_ex( con: tcod.console.Console, x: int, y: int, flag: int, alignment: int, fmt: str, ) -> None: """Print a string on a console using a blend mode and alignment mode. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. .. deprecated:: 8.5 Use :any:`Console.print_` instead. """ lib.TCOD_console_printf_ex(_console(con), x, y, flag, alignment, _fmt(fmt))
[ "def", "console_print_ex", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "flag", ":", "int", ",", "alignment", ":", "int", ",", "fmt", ":", "str", ",", ")", "->", "None", ":", "lib", ".", "TCOD_console_printf_ex", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "flag", ",", "alignment", ",", "_fmt", "(", "fmt", ")", ")" ]
Print a string on a console using a blend mode and alignment mode. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. .. deprecated:: 8.5 Use :any:`Console.print_` instead.
[ "Print", "a", "string", "on", "a", "console", "using", "a", "blend", "mode", "and", "alignment", "mode", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1367-L1385
train
libtcod/python-tcod
tcod/libtcodpy.py
console_print_rect_ex
def console_print_rect_ex( con: tcod.console.Console, x: int, y: int, w: int, h: int, flag: int, alignment: int, fmt: str, ) -> int: """Print a string constrained to a rectangle with blend and alignment. Returns: int: The number of lines of text once word-wrapped. .. deprecated:: 8.5 Use :any:`Console.print_rect` instead. """ return int( lib.TCOD_console_printf_rect_ex( _console(con), x, y, w, h, flag, alignment, _fmt(fmt) ) )
python
def console_print_rect_ex( con: tcod.console.Console, x: int, y: int, w: int, h: int, flag: int, alignment: int, fmt: str, ) -> int: """Print a string constrained to a rectangle with blend and alignment. Returns: int: The number of lines of text once word-wrapped. .. deprecated:: 8.5 Use :any:`Console.print_rect` instead. """ return int( lib.TCOD_console_printf_rect_ex( _console(con), x, y, w, h, flag, alignment, _fmt(fmt) ) )
[ "def", "console_print_rect_ex", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "w", ":", "int", ",", "h", ":", "int", ",", "flag", ":", "int", ",", "alignment", ":", "int", ",", "fmt", ":", "str", ",", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_console_printf_rect_ex", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "w", ",", "h", ",", "flag", ",", "alignment", ",", "_fmt", "(", "fmt", ")", ")", ")" ]
Print a string constrained to a rectangle with blend and alignment. Returns: int: The number of lines of text once word-wrapped. .. deprecated:: 8.5 Use :any:`Console.print_rect` instead.
[ "Print", "a", "string", "constrained", "to", "a", "rectangle", "with", "blend", "and", "alignment", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1412-L1434
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_height_rect
def console_get_height_rect( con: tcod.console.Console, x: int, y: int, w: int, h: int, fmt: str ) -> int: """Return the height of this text once word-wrapped into this rectangle. Returns: int: The number of lines of text once word-wrapped. .. deprecated:: 8.5 Use :any:`Console.get_height_rect` instead. """ return int( lib.TCOD_console_get_height_rect_fmt( _console(con), x, y, w, h, _fmt(fmt) ) )
python
def console_get_height_rect( con: tcod.console.Console, x: int, y: int, w: int, h: int, fmt: str ) -> int: """Return the height of this text once word-wrapped into this rectangle. Returns: int: The number of lines of text once word-wrapped. .. deprecated:: 8.5 Use :any:`Console.get_height_rect` instead. """ return int( lib.TCOD_console_get_height_rect_fmt( _console(con), x, y, w, h, _fmt(fmt) ) )
[ "def", "console_get_height_rect", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "w", ":", "int", ",", "h", ":", "int", ",", "fmt", ":", "str", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_console_get_height_rect_fmt", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "w", ",", "h", ",", "_fmt", "(", "fmt", ")", ")", ")" ]
Return the height of this text once word-wrapped into this rectangle. Returns: int: The number of lines of text once word-wrapped. .. deprecated:: 8.5 Use :any:`Console.get_height_rect` instead.
[ "Return", "the", "height", "of", "this", "text", "once", "word", "-", "wrapped", "into", "this", "rectangle", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1438-L1453
train
libtcod/python-tcod
tcod/libtcodpy.py
console_print_frame
def console_print_frame( con: tcod.console.Console, x: int, y: int, w: int, h: int, clear: bool = True, flag: int = BKGND_DEFAULT, fmt: str = "", ) -> None: """Draw a framed rectangle with optinal text. This uses the default background color and blend mode to fill the rectangle and the default foreground to draw the outline. `fmt` will be printed on the inside of the rectangle, word-wrapped. If `fmt` is empty then no title will be drawn. .. versionchanged:: 8.2 Now supports Unicode strings. .. deprecated:: 8.5 Use :any:`Console.print_frame` instead. """ fmt = _fmt(fmt) if fmt else ffi.NULL lib.TCOD_console_printf_frame(_console(con), x, y, w, h, clear, flag, fmt)
python
def console_print_frame( con: tcod.console.Console, x: int, y: int, w: int, h: int, clear: bool = True, flag: int = BKGND_DEFAULT, fmt: str = "", ) -> None: """Draw a framed rectangle with optinal text. This uses the default background color and blend mode to fill the rectangle and the default foreground to draw the outline. `fmt` will be printed on the inside of the rectangle, word-wrapped. If `fmt` is empty then no title will be drawn. .. versionchanged:: 8.2 Now supports Unicode strings. .. deprecated:: 8.5 Use :any:`Console.print_frame` instead. """ fmt = _fmt(fmt) if fmt else ffi.NULL lib.TCOD_console_printf_frame(_console(con), x, y, w, h, clear, flag, fmt)
[ "def", "console_print_frame", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "w", ":", "int", ",", "h", ":", "int", ",", "clear", ":", "bool", "=", "True", ",", "flag", ":", "int", "=", "BKGND_DEFAULT", ",", "fmt", ":", "str", "=", "\"\"", ",", ")", "->", "None", ":", "fmt", "=", "_fmt", "(", "fmt", ")", "if", "fmt", "else", "ffi", ".", "NULL", "lib", ".", "TCOD_console_printf_frame", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ",", "w", ",", "h", ",", "clear", ",", "flag", ",", "fmt", ")" ]
Draw a framed rectangle with optinal text. This uses the default background color and blend mode to fill the rectangle and the default foreground to draw the outline. `fmt` will be printed on the inside of the rectangle, word-wrapped. If `fmt` is empty then no title will be drawn. .. versionchanged:: 8.2 Now supports Unicode strings. .. deprecated:: 8.5 Use :any:`Console.print_frame` instead.
[ "Draw", "a", "framed", "rectangle", "with", "optinal", "text", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1513-L1538
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_default_background
def console_get_default_background(con: tcod.console.Console) -> Color: """Return this consoles default background color. .. deprecated:: 8.5 Use :any:`Console.default_bg` instead. """ return Color._new_from_cdata( lib.TCOD_console_get_default_background(_console(con)) )
python
def console_get_default_background(con: tcod.console.Console) -> Color: """Return this consoles default background color. .. deprecated:: 8.5 Use :any:`Console.default_bg` instead. """ return Color._new_from_cdata( lib.TCOD_console_get_default_background(_console(con)) )
[ "def", "console_get_default_background", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "Color", ":", "return", "Color", ".", "_new_from_cdata", "(", "lib", ".", "TCOD_console_get_default_background", "(", "_console", "(", "con", ")", ")", ")" ]
Return this consoles default background color. .. deprecated:: 8.5 Use :any:`Console.default_bg` instead.
[ "Return", "this", "consoles", "default", "background", "color", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1558-L1566
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_default_foreground
def console_get_default_foreground(con: tcod.console.Console) -> Color: """Return this consoles default foreground color. .. deprecated:: 8.5 Use :any:`Console.default_fg` instead. """ return Color._new_from_cdata( lib.TCOD_console_get_default_foreground(_console(con)) )
python
def console_get_default_foreground(con: tcod.console.Console) -> Color: """Return this consoles default foreground color. .. deprecated:: 8.5 Use :any:`Console.default_fg` instead. """ return Color._new_from_cdata( lib.TCOD_console_get_default_foreground(_console(con)) )
[ "def", "console_get_default_foreground", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "Color", ":", "return", "Color", ".", "_new_from_cdata", "(", "lib", ".", "TCOD_console_get_default_foreground", "(", "_console", "(", "con", ")", ")", ")" ]
Return this consoles default foreground color. .. deprecated:: 8.5 Use :any:`Console.default_fg` instead.
[ "Return", "this", "consoles", "default", "foreground", "color", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1570-L1578
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_char_background
def console_get_char_background( con: tcod.console.Console, x: int, y: int ) -> Color: """Return the background color at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.bg`. """ return Color._new_from_cdata( lib.TCOD_console_get_char_background(_console(con), x, y) )
python
def console_get_char_background( con: tcod.console.Console, x: int, y: int ) -> Color: """Return the background color at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.bg`. """ return Color._new_from_cdata( lib.TCOD_console_get_char_background(_console(con), x, y) )
[ "def", "console_get_char_background", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Color", ":", "return", "Color", ".", "_new_from_cdata", "(", "lib", ".", "TCOD_console_get_char_background", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ")", ")" ]
Return the background color at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.bg`.
[ "Return", "the", "background", "color", "at", "the", "x", "y", "of", "this", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1582-L1593
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_char_foreground
def console_get_char_foreground( con: tcod.console.Console, x: int, y: int ) -> Color: """Return the foreground color at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.fg`. """ return Color._new_from_cdata( lib.TCOD_console_get_char_foreground(_console(con), x, y) )
python
def console_get_char_foreground( con: tcod.console.Console, x: int, y: int ) -> Color: """Return the foreground color at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.fg`. """ return Color._new_from_cdata( lib.TCOD_console_get_char_foreground(_console(con), x, y) )
[ "def", "console_get_char_foreground", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Color", ":", "return", "Color", ".", "_new_from_cdata", "(", "lib", ".", "TCOD_console_get_char_foreground", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ")", ")" ]
Return the foreground color at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.fg`.
[ "Return", "the", "foreground", "color", "at", "the", "x", "y", "of", "this", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1597-L1608
train
libtcod/python-tcod
tcod/libtcodpy.py
console_get_char
def console_get_char(con: tcod.console.Console, x: int, y: int) -> int: """Return the character at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.ch`. """ return lib.TCOD_console_get_char(_console(con), x, y)
python
def console_get_char(con: tcod.console.Console, x: int, y: int) -> int: """Return the character at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.ch`. """ return lib.TCOD_console_get_char(_console(con), x, y)
[ "def", "console_get_char", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "int", ":", "return", "lib", ".", "TCOD_console_get_char", "(", "_console", "(", "con", ")", ",", "x", ",", "y", ")" ]
Return the character at the x,y of this console. .. deprecated:: 8.4 Array access performs significantly faster than using this function. See :any:`Console.ch`.
[ "Return", "the", "character", "at", "the", "x", "y", "of", "this", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1612-L1619
train
libtcod/python-tcod
tcod/libtcodpy.py
console_wait_for_keypress
def console_wait_for_keypress(flush: bool) -> Key: """Block until the user presses a key, then returns a new Key. Args: flush bool: If True then the event queue is cleared before waiting for the next event. Returns: Key: A new Key instance. .. deprecated:: 9.3 Use the :any:`tcod.event.wait` function to wait for events. """ key = Key() lib.TCOD_console_wait_for_keypress_wrapper(key.key_p, flush) return key
python
def console_wait_for_keypress(flush: bool) -> Key: """Block until the user presses a key, then returns a new Key. Args: flush bool: If True then the event queue is cleared before waiting for the next event. Returns: Key: A new Key instance. .. deprecated:: 9.3 Use the :any:`tcod.event.wait` function to wait for events. """ key = Key() lib.TCOD_console_wait_for_keypress_wrapper(key.key_p, flush) return key
[ "def", "console_wait_for_keypress", "(", "flush", ":", "bool", ")", "->", "Key", ":", "key", "=", "Key", "(", ")", "lib", ".", "TCOD_console_wait_for_keypress_wrapper", "(", "key", ".", "key_p", ",", "flush", ")", "return", "key" ]
Block until the user presses a key, then returns a new Key. Args: flush bool: If True then the event queue is cleared before waiting for the next event. Returns: Key: A new Key instance. .. deprecated:: 9.3 Use the :any:`tcod.event.wait` function to wait for events.
[ "Block", "until", "the", "user", "presses", "a", "key", "then", "returns", "a", "new", "Key", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1639-L1654
train
libtcod/python-tcod
tcod/libtcodpy.py
console_from_file
def console_from_file(filename: str) -> tcod.console.Console: """Return a new console object from a filename. The file format is automactially determined. This can load REXPaint `.xp`, ASCII Paint `.apf`, or Non-delimited ASCII `.asc` files. Args: filename (Text): The path to the file, as a string. Returns: A new :any`Console` instance. """ return tcod.console.Console._from_cdata( lib.TCOD_console_from_file(filename.encode("utf-8")) )
python
def console_from_file(filename: str) -> tcod.console.Console: """Return a new console object from a filename. The file format is automactially determined. This can load REXPaint `.xp`, ASCII Paint `.apf`, or Non-delimited ASCII `.asc` files. Args: filename (Text): The path to the file, as a string. Returns: A new :any`Console` instance. """ return tcod.console.Console._from_cdata( lib.TCOD_console_from_file(filename.encode("utf-8")) )
[ "def", "console_from_file", "(", "filename", ":", "str", ")", "->", "tcod", ".", "console", ".", "Console", ":", "return", "tcod", ".", "console", ".", "Console", ".", "_from_cdata", "(", "lib", ".", "TCOD_console_from_file", "(", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")", ")" ]
Return a new console object from a filename. The file format is automactially determined. This can load REXPaint `.xp`, ASCII Paint `.apf`, or Non-delimited ASCII `.asc` files. Args: filename (Text): The path to the file, as a string. Returns: A new :any`Console` instance.
[ "Return", "a", "new", "console", "object", "from", "a", "filename", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1685-L1698
train
libtcod/python-tcod
tcod/libtcodpy.py
console_blit
def console_blit( src: tcod.console.Console, x: int, y: int, w: int, h: int, dst: tcod.console.Console, xdst: int, ydst: int, ffade: float = 1.0, bfade: float = 1.0, ) -> None: """Blit the console src from x,y,w,h to console dst at xdst,ydst. .. deprecated:: 8.5 Call the :any:`Console.blit` method instead. """ lib.TCOD_console_blit( _console(src), x, y, w, h, _console(dst), xdst, ydst, ffade, bfade )
python
def console_blit( src: tcod.console.Console, x: int, y: int, w: int, h: int, dst: tcod.console.Console, xdst: int, ydst: int, ffade: float = 1.0, bfade: float = 1.0, ) -> None: """Blit the console src from x,y,w,h to console dst at xdst,ydst. .. deprecated:: 8.5 Call the :any:`Console.blit` method instead. """ lib.TCOD_console_blit( _console(src), x, y, w, h, _console(dst), xdst, ydst, ffade, bfade )
[ "def", "console_blit", "(", "src", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "w", ":", "int", ",", "h", ":", "int", ",", "dst", ":", "tcod", ".", "console", ".", "Console", ",", "xdst", ":", "int", ",", "ydst", ":", "int", ",", "ffade", ":", "float", "=", "1.0", ",", "bfade", ":", "float", "=", "1.0", ",", ")", "->", "None", ":", "lib", ".", "TCOD_console_blit", "(", "_console", "(", "src", ")", ",", "x", ",", "y", ",", "w", ",", "h", ",", "_console", "(", "dst", ")", ",", "xdst", ",", "ydst", ",", "ffade", ",", "bfade", ")" ]
Blit the console src from x,y,w,h to console dst at xdst,ydst. .. deprecated:: 8.5 Call the :any:`Console.blit` method instead.
[ "Blit", "the", "console", "src", "from", "x", "y", "w", "h", "to", "console", "dst", "at", "xdst", "ydst", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1702-L1721
train
libtcod/python-tcod
tcod/libtcodpy.py
console_delete
def console_delete(con: tcod.console.Console) -> None: """Closes the window if `con` is the root console. libtcod objects are automatically garbage collected once they go out of scope. This function exists for backwards compatibility. .. deprecated:: 9.3 This function is not needed for normal :any:`tcod.console.Console`'s. The root console should be used in a with statement instead to ensure that it closes. """ con = _console(con) if con == ffi.NULL: lib.TCOD_console_delete(con) warnings.warn( "Instead of this call you should use a with statement to ensure" " the root console closes, for example:" "\n with tcod.console_init_root(...) as root_console:" "\n ...", DeprecationWarning, stacklevel=2, ) else: warnings.warn( "You no longer need to make this call, " "Console's are deleted when they go out of scope.", DeprecationWarning, stacklevel=2, )
python
def console_delete(con: tcod.console.Console) -> None: """Closes the window if `con` is the root console. libtcod objects are automatically garbage collected once they go out of scope. This function exists for backwards compatibility. .. deprecated:: 9.3 This function is not needed for normal :any:`tcod.console.Console`'s. The root console should be used in a with statement instead to ensure that it closes. """ con = _console(con) if con == ffi.NULL: lib.TCOD_console_delete(con) warnings.warn( "Instead of this call you should use a with statement to ensure" " the root console closes, for example:" "\n with tcod.console_init_root(...) as root_console:" "\n ...", DeprecationWarning, stacklevel=2, ) else: warnings.warn( "You no longer need to make this call, " "Console's are deleted when they go out of scope.", DeprecationWarning, stacklevel=2, )
[ "def", "console_delete", "(", "con", ":", "tcod", ".", "console", ".", "Console", ")", "->", "None", ":", "con", "=", "_console", "(", "con", ")", "if", "con", "==", "ffi", ".", "NULL", ":", "lib", ".", "TCOD_console_delete", "(", "con", ")", "warnings", ".", "warn", "(", "\"Instead of this call you should use a with statement to ensure\"", "\" the root console closes, for example:\"", "\"\\n with tcod.console_init_root(...) as root_console:\"", "\"\\n ...\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ",", ")", "else", ":", "warnings", ".", "warn", "(", "\"You no longer need to make this call, \"", "\"Console's are deleted when they go out of scope.\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ",", ")" ]
Closes the window if `con` is the root console. libtcod objects are automatically garbage collected once they go out of scope. This function exists for backwards compatibility. .. deprecated:: 9.3 This function is not needed for normal :any:`tcod.console.Console`'s. The root console should be used in a with statement instead to ensure that it closes.
[ "Closes", "the", "window", "if", "con", "is", "the", "root", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1741-L1771
train
libtcod/python-tcod
tcod/libtcodpy.py
console_fill_foreground
def console_fill_foreground( con: tcod.console.Console, r: Sequence[int], g: Sequence[int], b: Sequence[int], ) -> None: """Fill the foregound of a console with r,g,b. Args: con (Console): Any Console instance. r (Sequence[int]): An array of integers with a length of width*height. g (Sequence[int]): An array of integers with a length of width*height. b (Sequence[int]): An array of integers with a length of width*height. .. deprecated:: 8.4 You should assign to :any:`tcod.console.Console.fg` instead. """ if len(r) != len(g) or len(r) != len(b): raise TypeError("R, G and B must all have the same size.") if ( isinstance(r, np.ndarray) and isinstance(g, np.ndarray) and isinstance(b, np.ndarray) ): # numpy arrays, use numpy's ctypes functions r_ = np.ascontiguousarray(r, dtype=np.intc) g_ = np.ascontiguousarray(g, dtype=np.intc) b_ = np.ascontiguousarray(b, dtype=np.intc) cr = ffi.cast("int *", r_.ctypes.data) cg = ffi.cast("int *", g_.ctypes.data) cb = ffi.cast("int *", b_.ctypes.data) else: # otherwise convert using ffi arrays cr = ffi.new("int[]", r) cg = ffi.new("int[]", g) cb = ffi.new("int[]", b) lib.TCOD_console_fill_foreground(_console(con), cr, cg, cb)
python
def console_fill_foreground( con: tcod.console.Console, r: Sequence[int], g: Sequence[int], b: Sequence[int], ) -> None: """Fill the foregound of a console with r,g,b. Args: con (Console): Any Console instance. r (Sequence[int]): An array of integers with a length of width*height. g (Sequence[int]): An array of integers with a length of width*height. b (Sequence[int]): An array of integers with a length of width*height. .. deprecated:: 8.4 You should assign to :any:`tcod.console.Console.fg` instead. """ if len(r) != len(g) or len(r) != len(b): raise TypeError("R, G and B must all have the same size.") if ( isinstance(r, np.ndarray) and isinstance(g, np.ndarray) and isinstance(b, np.ndarray) ): # numpy arrays, use numpy's ctypes functions r_ = np.ascontiguousarray(r, dtype=np.intc) g_ = np.ascontiguousarray(g, dtype=np.intc) b_ = np.ascontiguousarray(b, dtype=np.intc) cr = ffi.cast("int *", r_.ctypes.data) cg = ffi.cast("int *", g_.ctypes.data) cb = ffi.cast("int *", b_.ctypes.data) else: # otherwise convert using ffi arrays cr = ffi.new("int[]", r) cg = ffi.new("int[]", g) cb = ffi.new("int[]", b) lib.TCOD_console_fill_foreground(_console(con), cr, cg, cb)
[ "def", "console_fill_foreground", "(", "con", ":", "tcod", ".", "console", ".", "Console", ",", "r", ":", "Sequence", "[", "int", "]", ",", "g", ":", "Sequence", "[", "int", "]", ",", "b", ":", "Sequence", "[", "int", "]", ",", ")", "->", "None", ":", "if", "len", "(", "r", ")", "!=", "len", "(", "g", ")", "or", "len", "(", "r", ")", "!=", "len", "(", "b", ")", ":", "raise", "TypeError", "(", "\"R, G and B must all have the same size.\"", ")", "if", "(", "isinstance", "(", "r", ",", "np", ".", "ndarray", ")", "and", "isinstance", "(", "g", ",", "np", ".", "ndarray", ")", "and", "isinstance", "(", "b", ",", "np", ".", "ndarray", ")", ")", ":", "# numpy arrays, use numpy's ctypes functions", "r_", "=", "np", ".", "ascontiguousarray", "(", "r", ",", "dtype", "=", "np", ".", "intc", ")", "g_", "=", "np", ".", "ascontiguousarray", "(", "g", ",", "dtype", "=", "np", ".", "intc", ")", "b_", "=", "np", ".", "ascontiguousarray", "(", "b", ",", "dtype", "=", "np", ".", "intc", ")", "cr", "=", "ffi", ".", "cast", "(", "\"int *\"", ",", "r_", ".", "ctypes", ".", "data", ")", "cg", "=", "ffi", ".", "cast", "(", "\"int *\"", ",", "g_", ".", "ctypes", ".", "data", ")", "cb", "=", "ffi", ".", "cast", "(", "\"int *\"", ",", "b_", ".", "ctypes", ".", "data", ")", "else", ":", "# otherwise convert using ffi arrays", "cr", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "r", ")", "cg", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "g", ")", "cb", "=", "ffi", ".", "new", "(", "\"int[]\"", ",", "b", ")", "lib", ".", "TCOD_console_fill_foreground", "(", "_console", "(", "con", ")", ",", "cr", ",", "cg", ",", "cb", ")" ]
Fill the foregound of a console with r,g,b. Args: con (Console): Any Console instance. r (Sequence[int]): An array of integers with a length of width*height. g (Sequence[int]): An array of integers with a length of width*height. b (Sequence[int]): An array of integers with a length of width*height. .. deprecated:: 8.4 You should assign to :any:`tcod.console.Console.fg` instead.
[ "Fill", "the", "foregound", "of", "a", "console", "with", "r", "g", "b", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1775-L1812
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train