Add generalized version of wrap function

This commit is contained in:
Yuri Rubinsky
2022-06-27 12:37:55 +03:00
parent 898e09e2e6
commit 2476c50a66
2 changed files with 68 additions and 0 deletions

View File

@@ -1040,6 +1040,27 @@
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
</description>
</method>
<method name="wrap">
<return type="Variant" />
<argument index="0" name="value" type="Variant" />
<argument index="1" name="min" type="Variant" />
<argument index="2" name="max" type="Variant" />
<description>
Wraps the [Variant] [code]value[/code] between [code]min[/code] and [code]max[/code].
Usable for creating loop-alike behavior or infinite surfaces.
Variant types [int] and [float] (real) are supported. If any of the argument is [float] the result will be [float], otherwise it is [int].
[codeblock]
var a = wrap(4, 5, 10)
# a is 9 (int)
var a = wrap(7, 5, 10)
# a is 7 (int)
var a = wrap(10.5, 5, 10)
# a is 5.5 (float)
[/codeblock]
</description>
</method>
<method name="wrapf">
<return type="float" />
<argument index="0" name="value" type="float" />