Module gdnative::globalscope
source · Expand description
Port of selected GDScript built-in functions.
This module contains some of the functions available in the @GDScript documentation.
Reasons why a GDScript function may not be ported to Rust include:
- they are in the Rust standard library (
abs
,sin
,floor
,assert
, …) - they are already part of a godot-rust API
print
->godot_print!
instance_from_id
->GodotObject::from_instance_id()
- …
- they have a private implementation, i.e. a Rust port would have different semantics
randi
,randf
etc. – users should userand
cratestr2var
,bytes2var
,hash
etc – to be verified
This above list is not a definitive inclusion/exclusion criterion, just a rough guideline.
Other noteworthy special cases:
- GDScript
fmod
corresponds to Rust’s%
operator onf32
(also known as theRem
trait).
Functions§
- Coordinate system conversion: cartesian -> polar
- Converts from decibels to linear energy (audio).
- Returns an “eased” value of x based on an easing function defined with
curve
. - Returns the floating-point modulus of
a/b
that wraps equally in positive and negative. - Find linear interpolation weight from interpolated values.
- Returns
true
ifa
andb
are approximately equal to each other. - Returns true if
s
is zero or almost zero. - Linearly interpolates between two values, by the factor defined in weight.
- Linearly interpolates between two angles (in radians), by a normalized value.
- Converts from linear energy to decibels (audio).
- Loads a resource from the filesystem located at
path
. - Moves
range.start()
towardrange.end()
by thedelta
value. - Returns the nearest equal or larger power of 2 for an integer value.
- Coordinate system conversion: polar -> cartesian
- Returns the integer modulus of
a/b
that wraps equally in positive and negative. - Maps a value from
range_from
torange_to
, using linear interpolation. - Smooth (Hermite) interpolation.
- Position of the first non-zero digit, after the decimal point.
- Snaps float value
s
to a givenstep
. - Wraps float value between
min
andmax
. - Wraps integer value between
min
andmax
.