Maths (PE.maths)
PE.maths.BaseN
class uses:
organize all BaseN (mathematical bases convertor) functions
BaseN.base_n(n: int)
gives you a baseN string of the baseN that you want (for example, baseN 10= "0123456789", or baseN 2= "01").
you can get any baseN until baseN 92.
warning! this function may not work with any system, especially because the fact that any system uses its own shape, for example base 16 can be "0123456789ABCDEF" or "0123456789abcdef" so when using external baseN systems, please make your own base (a string)
function actions:
returns a string of the symbols until your index.
​
parameters:
n - the index of your baseN (minimum of 1 and maximum of 92) (int)
​
returns:
a baseN string of the symbols up to your index (str)
BaseN.check_base(base: str)
check if a string is valid baseN string
​
parameters:
base - string to check (str)
​
returns:
is it valid baseN string (bool)
BaseN.dec_to_base(num: int, base: str)
convert int to baseN value.
​
parameters:
num - the number to convert (int)
base - the baseN string (str)
​
returns:
baseN value (str)
BaseN.base_to_dec(num: str, base: str)
convert baseN value to decimal (normal) number.
​
parameters:
num - baseN value (str)
base - baseN string (str)
​
returns:
decimal number (int)
PE.maths.Bytes
No docs available yet.
almost useless type that may be removed soon
PE.maths.FixedRange
No docs available yet.
may be removed soon
but in a nutshell, this class is a type of a range() that can contains floats. __init__ almost same as range() type, and it has 2 functions that returns the range as tuple() or range() types.
PE.maths.TileMap
great way to do tilemaps and store data in vector2 matrix.
​
class uses:
store and manage tilemaps.
TileMap.__init__(self, size: pygame.math.Vector2, fill=None)
function actions:
initializing new TileMap object.
​
parameters:
size - the size of the TileMap (vector2 like)
fill - the initial value of all tiles, the default value (any)
TileMap.fill(self, fill=None)
fill the whole TileMap with a value
​
function actions:
sets every tile to specific value
​
parameters:
fill - the value to fill (any)
​
​
TileMap.get_size(self)
get the size of the TIleMap
​
returns:
the size of the tilemap (Vector2 like)
TileMap.set_tile(self, data, x, y=None)
*when y is None, x have to be vector2.
​
function actions:
set a tile in the tileMap to specific value
​
parameters:
data - the value to set the tile to (any)
x - the x index of the tile / the index value of the tile (int / vector2 like)
y - the y index of the tile (int)
TileMap.get_tile(self, x, y=None)
*when y is None, x have to be vector2.
​
function actions:
get the value of specific tile in the TileMap
​
parameters:
x - the x index of the tile / the index value of the tile (int / vector2 like)
y - the y index of the tile (int)
​
returns:
the value of the tile (any)
PE.maths.root_n(num, root=2)
function actions:
simply do num**(1/root)
​
parameters:
num - number to get its root (int/float)
root - the root to do on it (int/float)
​
returns:
result (int/float)
PE.maths.fixed_float(num: float, num_of_zeros=3)
function actions:
make a float number shorter. (good for present floats on screen inside a game)
​
parameters:
num - the original float (float)
num_of_zeros - the count of numbers after the dot that will be presented (int)
​
returns:
shorter float (float)
PE.maths.fixed_int(num: int)
function actions:
presents huge numbers as huge numbers. (for example: 9000000 = '9M', can be used to present huge numbers on the screen inside a game)
​
parameters:
num - the huge number to make shorten (int/float)
​
returns:
shorter number (str)
PE.maths.fixed_isnumeric(string: str, return_number=False, raise_error=False)
better version of str.isnumeric(). instead of check if a string contains only 1,2,3,4,5,6,7,8,9,0 characters like str.is_numeric() does, fixed_isnumeric check if a string can be converted to int/float types (for example, regular isnumeric will return False for "-57" and "9.45" but fixed_isnumeric will return True instead).
​
function actions:
checking if the string can be converted to int or float, and returns dynamic output.
​
parameters:
string - the string you want to check (str)
return_number - set True to get output of the int/float value or set False to get a bool output of this can be converted (bool)
raise_error - set True to raise error when the string cannot be converted to number. (bool)
​
returns:
depend on the parameters (bool/int/float/str)
PE.maths.float_in_range(num: float, num_range: range)
function actions:
check if a float number is inside a python range.
​
parameters:
num - float to check (float)
num_range - range to check (range)
​
returns:
is the float number inside the range (bool)
PE.maths.string_in_range(num: str, num_range: range)
function actions:
check if a string is a number and if so, is it inside a python range.
​
parameters:
num - string to check (str)
num_range - range to check (range)
​
returns:
is the string a number and inside the range (bool)
