idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
242,000
def _get_pathcost_func ( name : str ) -> Callable [ [ int , int , int , int , Any ] , float ] : return ffi . cast ( "TCOD_path_func_t" , ffi . addressof ( lib , name ) )
Return a properly cast PathCostArray callback .
242,001
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 .
242,002
def poll_event ( self ) : for e in tdl . event . get ( ) : 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 .
242,003
def _new_from_cdata ( cls , cdata : Any ) -> "Random" : self = object . __new__ ( cls ) self . random_c = cdata return self
Return a new instance encapsulating this cdata .
242,004
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 .
242,005
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 .
242,006
def get_point ( self , * 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 .
242,007
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)" % transparen...
Return the visible area of a field - of - view computation .
242,008
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 .
242,009
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...
Sample a mesh - grid array and return the result .
242,010
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 ( [ ...
Sample an open mesh - grid array and return the result .
242,011
def _processEvents ( ) : global _mousel , _mousem , _mouser , _eventsflushed , _pushedEvents _eventsflushed = True events = _pushedEvents _pushedEvents = [ ] 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 , libk...
Flushes the event queue from libtcod into the global list _eventQueue
242,012
def wait ( timeout = None , flush = True ) : if timeout is not None : timeout = timeout + _time . clock ( ) while True : if _eventQueue : return _eventQueue . pop ( 0 ) if flush : _tdl . flush ( ) if timeout and _time . clock ( ) >= timeout : return None _time . sleep ( 0.001 ) _processEvents ( )
Wait for an event .
242,013
def run_once ( self ) : if not hasattr ( self , '_App__prevTime' ) : self . __prevTime = _time . clock ( ) for event in get ( ) : if event . type : method = 'ev_%s' % event . type getattr ( self , method ) ( event ) if event . type == 'KEYDOWN' : method = 'key_%s' % event . key if hasattr ( self , method ) : getattr ( ...
Pump events to this App instance and then return .
242,014
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 .
242,015
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 .
242,016
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 .
242,017
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 ...
Upload a tile into this array .
242,018
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 .
242,019
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...
Return names and values from tcod . lib .
242,020
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 ( ) : f . write ( "%s = ...
Write libtcod constants into the tcod . constants module .
242,021
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...
Replace enumerator expressions with ... stubs .
242,022
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 .
242,023
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
242,024
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 .
242,025
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 .
242,026
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 ...
Return a smoothly defined scale of colors .
242,027
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 : title = os . path . basename ( sys . argv [ 0 ] ) if renderer is None : warnings . warn ( "A renderer shou...
Set up the primary display and return the root console .
242,028
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 ...
Load the custom font file at fontFile .
242,029
def console_get_width ( con : tcod . console . Console ) -> int : return int ( lib . TCOD_console_get_width ( _console ( con ) ) )
Return the width of a console .
242,030
def console_get_height ( con : tcod . console . Console ) -> int : return int ( lib . TCOD_console_get_height ( _console ( con ) ) )
Return the height of a console .
242,031
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 .
242,032
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 .
242,033
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 .
242,034
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 .
242,035
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 .
242,036
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 .
242,037
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 .
242,038
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 .
242,039
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 .
242,040
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 .
242,041
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 .
242,042
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 .
242,043
def console_get_alignment ( con : tcod . console . Console ) -> int : return int ( lib . TCOD_console_get_alignment ( _console ( con ) ) )
Return this consoles current alignment mode .
242,044
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 .
242,045
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 .
242,046
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 .
242,047
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 .
242,048
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 .
242,049
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 .
242,050
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 .
242,051
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 .
242,052
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 .
242,053
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 .
242,054
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 .
242,055
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 .
242,056
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_cons...
Closes the window if con is the root console .
242,057
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...
Fill the foregound of a console with r g b .
242,058
def console_fill_char ( con : tcod . console . Console , arr : Sequence [ int ] ) -> None : if isinstance ( arr , np . ndarray ) : np_array = np . ascontiguousarray ( arr , dtype = np . intc ) carr = ffi . cast ( "int *" , np_array . ctypes . data ) else : carr = ffi . new ( "int[]" , arr ) lib . TCOD_console_fill_char...
Fill the character tiles of a console with an array .
242,059
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 .
242,060
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 .
242,061
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 .
242,062
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 .
242,063
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 .
242,064
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 .
242,065
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 .
242,066
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_l...
Return a list of consoles from a REXPaint . xp file .
242,067
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...
Save a list of consoles to a REXPaint . xp file .
242,068
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 .
242,069
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 .
242,070
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 .
242,071
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 .
242,072
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 .
242,073
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 .
242,074
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 .
242,075
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 ...
Return a new TCOD_heightmap_t instance using an array .
242,076
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 .
242,077
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" ] ...
Set the value of a point on a heightmap .
242,078
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
242,079
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 .
242,080
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 .
242,081
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 .
242,082
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 .
242,083
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 . NUL...
Simulate the effect of rain drops on the terrain resulting in erosion .
242,084
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_...
Apply a generic transformation on the map so that each resulting cell value is the weighted sum of several neighbour cells .
242,085
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...
Add values from a Voronoi diagram to the heightmap .
242,086
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...
Add FBM noise to the heightmap .
242,087
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 , endR...
Carve a path along a cubic Bezier curve .
242,088
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 .
242,089
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 .
242,090
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 .
242,091
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 .
242,092
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 .
242,093
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 .
242,094
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 .
242,095
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 .
242,096
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 .
242,097
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 ) : yie...
returns an Iterable
242,098
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*"...
Return a NumPy index array following a Bresenham line .
242,099
def map_copy ( source : tcod . map . Map , dest : tcod . map . Map ) -> None : if source . width != dest . width or source . height != dest . height : dest . __init__ ( source . width , source . height , source . _order ) dest . _Map__buffer [ : ] = source . _Map__buffer [ : ]
Copy map data from source to dest .