Improve the `@GDScript.inverse_lerp()` documentation
This closes https://github.com/godotengine/godot-docs/issues/2589.
(cherry picked from commit 6b5573700b
)
This commit is contained in:
parent
4e879ed803
commit
21a45dda7a
|
@ -490,9 +490,13 @@
|
||||||
<argument index="2" name="weight" type="float">
|
<argument index="2" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns a normalized value considering the given range.
|
Returns a normalized value considering the given range. This is the opposite of [method lerp].
|
||||||
[codeblock]
|
[codeblock]
|
||||||
inverse_lerp(3, 5, 4) # Returns 0.5
|
var middle = lerp(20, 30, 0.75)
|
||||||
|
# `middle` is now 27.5.
|
||||||
|
# Now, we pretend to have forgotten the original ratio and want to get it back.
|
||||||
|
var ratio = inverse_lerp(20, 30, 27.5)
|
||||||
|
# `ratio` is now 0.75.
|
||||||
[/codeblock]
|
[/codeblock]
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
@ -567,7 +571,7 @@
|
||||||
<argument index="2" name="weight" type="float">
|
<argument index="2" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Linearly interpolates between two values by a normalized value.
|
Linearly interpolates between two values by a normalized value. This is the opposite of [method inverse_lerp].
|
||||||
If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float].
|
If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float].
|
||||||
If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method).
|
If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method).
|
||||||
[codeblock]
|
[codeblock]
|
||||||
|
@ -587,7 +591,7 @@
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Linearly interpolates between two angles (in radians) by a normalized value.
|
Linearly interpolates between two angles (in radians) by a normalized value.
|
||||||
Similar to [method lerp] but interpolate correctly when the angles wrap around [constant @GDScript.TAU].
|
Similar to [method lerp], but interpolates correctly when the angles wrap around [constant @GDScript.TAU].
|
||||||
[codeblock]
|
[codeblock]
|
||||||
extends Sprite
|
extends Sprite
|
||||||
var elapsed = 0.0
|
var elapsed = 0.0
|
||||||
|
|
Loading…
Reference in New Issue