summaryrefslogtreecommitdiff
path: root/doc/classes
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-24 18:54:49 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-24 18:54:49 +0100
commit4a8b725bc9ba3126b8e318dd19d49b2472267fc2 (patch)
tree59816ba86429090f390a10e7985eec278b1783df /doc/classes
parent5e2bb98eee283aa06b424a53e9b10fa1b32f10cf (diff)
parente26f0906f229f237ad22d5b1986c1669b354b791 (diff)
Merge pull request #68386 from MewPurPur/snappedi-snappedf
Implement snappedi, snappedf, and Vector[2/3/4]i.snapped
Diffstat (limited to 'doc/classes')
-rw-r--r--doc/classes/@GlobalScope.xml59
-rw-r--r--doc/classes/Vector2.xml16
-rw-r--r--doc/classes/Vector2i.xml9
-rw-r--r--doc/classes/Vector3.xml12
-rw-r--r--doc/classes/Vector3i.xml9
-rw-r--r--doc/classes/Vector4.xml10
-rw-r--r--doc/classes/Vector4i.xml9
7 files changed, 89 insertions, 35 deletions
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 3eb0d3eaf3..33afe38446 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -16,7 +16,7 @@
<return type="Variant" />
<param index="0" name="x" type="Variant" />
<description>
- Returns the absolute value of a [Variant] parameter [param x] (i.e. non-negative value). Variant types [int], [float], [Vector2], [Vector2i], [Vector3] and [Vector3i] are supported.
+ Returns the absolute value of a [Variant] parameter [param x] (i.e. non-negative value). Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
var a = abs(-1)
# a is 1
@@ -36,6 +36,7 @@
var f = abs(Vector3i(-7, -8, -9))
# f is (7, 8, 9)
[/codeblock]
+ [b]Note:[/b] For better type safety, use [method absf], [method absi], [method Vector2.abs], [method Vector2i.abs], [method Vector3.abs], [method Vector3i.abs], [method Vector4.abs], or [method Vector4i.abs].
</description>
</method>
<method name="absf">
@@ -154,7 +155,7 @@
i = ceil(1.001) # i is 2.0
[/codeblock]
See also [method floor], [method round], and [method snapped].
- [b]Note:[/b] For better type safety, see [method ceilf], [method ceili], [method Vector2.ceil], [method Vector3.ceil] and [method Vector4.ceil].
+ [b]Note:[/b] For better type safety, use [method ceilf], [method ceili], [method Vector2.ceil], [method Vector3.ceil], or [method Vector4.ceil].
</description>
</method>
<method name="ceilf">
@@ -179,7 +180,7 @@
<param index="1" name="min" type="Variant" />
<param index="2" name="max" type="Variant" />
<description>
- Clamps the [param value], returning a [Variant] not less than [param min] and not more than [param max]. Variant types [int], [float], [Vector2], [Vector2i], [Vector3] and [Vector3i] are supported.
+ Clamps the [param value], returning a [Variant] not less than [param min] and not more than [param max]. Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
var a = clamp(-10, -1, 5)
# a is -1
@@ -199,6 +200,7 @@
var f = clamp(Vector3i(-7, -8, -9), Vector3i(-1, 2, 3), Vector3i(-4, -5, -6))
# f is (-4, -5, -6)
[/codeblock]
+ [b]Note:[/b] For better type safety, use [method clampf], [method clampi], [method Vector2.clamp], [method Vector2i.clamp], [method Vector3.clamp], [method Vector3i.clamp], [method Vector4.clamp], or [method Vector4i.clamp].
</description>
</method>
<method name="clampf">
@@ -378,7 +380,7 @@
a = floor(-2.99) # a is -3.0
[/codeblock]
See also [method ceil], [method round], and [method snapped].
- [b]Note:[/b] For better type safety, see [method floorf], [method floori], [method Vector2.floor], [method Vector3.floor] and [method Vector4.floor].
+ [b]Note:[/b] For better type safety, use [method floorf], [method floori], [method Vector2.floor], [method Vector3.floor], or [method Vector4.floor].
</description>
</method>
<method name="floorf">
@@ -960,7 +962,7 @@
round(2.6) # Returns 3
[/codeblock]
See also [method floor], [method ceil], and [method snapped].
- [b]Note:[/b] For better type safety, use [method roundf], [method roundi], [method Vector2.round], [method Vector3.round] or [method Vector4.round], instead.
+ [b]Note:[/b] For better type safety, use [method roundf], [method roundi], [method Vector2.round], [method Vector3.round], or [method Vector4.round].
</description>
</method>
<method name="roundf">
@@ -997,21 +999,22 @@
<return type="Variant" />
<param index="0" name="x" type="Variant" />
<description>
- Returns the sign of [param x] as same type of [Variant] as [param x] with each component being -1, 0 and 1 for each negative, zero and positive values respectively. Variant types [int], [float], [Vector2], [Vector2i], [Vector3] and [Vector3i] are supported.
+ Returns the same type of [Variant] as [param x], with [code]-1[/code] for negative values, [code]1[/code] for positive values, and [code]0[/code] for zeros. Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
sign(-6.0) # Returns -1
sign(0.0) # Returns 0
sign(6.0) # Returns 1
- sign(Vector3(-6.0, 0.0, 6.0) # Returns (-1, 0, 1)
+ sign(Vector3(-6.0, 0.0, 6.0)) # Returns (-1, 0, 1)
[/codeblock]
+ [b]Note:[/b] For better type safety, use [method signf], [method signi], [method Vector2.sign], [method Vector2i.sign], [method Vector3.sign], [method Vector3i.sign], [method Vector4.sign], or [method Vector4i.sign].
</description>
</method>
<method name="signf">
<return type="float" />
<param index="0" name="x" type="float" />
<description>
- Returns the sign of [param x] as a [float]: -1.0 or 1.0. Returns 0.0 if [param x] is 0.0.
+ Returns [code]-1.0[/code] if [param x] is negative, [code]1.0[/code] if [param x] is positive, and [code]0.0[/code] if if [param x] is zero.
[codeblock]
sign(-6.5) # Returns -1.0
sign(0.0) # Returns 0.0
@@ -1023,7 +1026,7 @@
<return type="int" />
<param index="0" name="x" type="int" />
<description>
- Returns the sign of [param x] as an [int]: -1 or 1. Returns 0 if [param x] is 0.
+ Returns [code]-1[/code] if [param x] is negative, [code]1[/code] if [param x] is positive, and [code]0[/code] if if [param x] is zero.
[codeblock]
sign(-6) # Returns -1
sign(0) # Returns 0
@@ -1073,16 +1076,46 @@
</description>
</method>
<method name="snapped">
+ <return type="Variant" />
+ <param index="0" name="x" type="Variant" />
+ <param index="1" name="step" type="Variant" />
+ <description>
+ Returns the multiple of [param step] that is the closest to [param x]. This can also be used to round a floating point number to an arbitrary number of decimals.
+ The returned value is the same type of [Variant] as [param step]. Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
+ [codeblock]
+ snapped(100, 32) # Returns 96
+ snapped(3.14159, 0.01) # Returns 3.14
+
+ snapped(Vector2(34, 70), Vector2(8, 8)) # Returns (32, 72)
+ [/codeblock]
+ See also [method ceil], [method floor], and [method round].
+ [b]Note:[/b] For better type safety, use [method snappedf], [method snappedi], [method Vector2.snapped], [method Vector2i.snapped], [method Vector3.snapped], [method Vector3i.snapped], [method Vector4.snapped], or [method Vector4i.snapped].
+ </description>
+ </method>
+ <method name="snappedf">
<return type="float" />
<param index="0" name="x" type="float" />
<param index="1" name="step" type="float" />
<description>
- Snaps the float value [param x] to a given [param step]. This can also be used to round a floating point number to an arbitrary number of decimals.
+ Returns the multiple of [param step] that is the closest to [param x]. This can also be used to round a floating point number to an arbitrary number of decimals.
+ A type-safe version of [method snapped], returning a [float].
[codeblock]
- snapped(100, 32) # Returns 96
- snapped(3.14159, 0.01) # Returns 3.14
+ snapped(32.0, 2.5) # Returns 32.5
+ snapped(3.14159, 0.01) # Returns 3.14
+ [/codeblock]
+ </description>
+ </method>
+ <method name="snappedi">
+ <return type="int" />
+ <param index="0" name="x" type="float" />
+ <param index="1" name="step" type="int" />
+ <description>
+ Returns the multiple of [param step] that is the closest to [param x].
+ A type-safe version of [method snapped], returning an [int].
+ [codeblock]
+ snapped(53, 16) # Returns 48
+ snapped(4096, 100) # Returns 4100
[/codeblock]
- See also [method ceil], [method floor], and [method round].
</description>
</method>
<method name="sqrt">
diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml
index fac672c764..4156030d77 100644
--- a/doc/classes/Vector2.xml
+++ b/doc/classes/Vector2.xml
@@ -110,7 +110,7 @@
<return type="Vector2" />
<param index="0" name="n" type="Vector2" />
<description>
- Returns the vector "bounced off" from a plane defined by the given normal.
+ Returns a new vector "bounced off" from a plane defined by the given normal.
</description>
</method>
<method name="ceil" qualifiers="const">
@@ -287,7 +287,7 @@
<method name="normalized" qualifiers="const">
<return type="Vector2" />
<description>
- Returns the vector scaled to unit length. Equivalent to [code]v / v.length()[/code].
+ Returns a new vector scaled to unit length. Equivalent to [code]v / v.length()[/code].
</description>
</method>
<method name="orthogonal" qualifiers="const">
@@ -314,21 +314,21 @@
<return type="Vector2" />
<param index="0" name="b" type="Vector2" />
<description>
- Returns this vector projected onto the vector [code]b[/code].
+ Returns the result of projecting the vector onto the given vector [param b].
</description>
</method>
<method name="reflect" qualifiers="const">
<return type="Vector2" />
<param index="0" name="n" type="Vector2" />
<description>
- Returns the vector reflected (i.e. mirrored, or symmetric) over a line defined by the given direction vector [param n].
+ Returns the result of reflecting the vector from a line defined by the given direction vector [param n].
</description>
</method>
<method name="rotated" qualifiers="const">
<return type="Vector2" />
<param index="0" name="angle" type="float" />
<description>
- Returns the vector rotated by [param angle] (in radians). See also [method @GlobalScope.deg_to_rad].
+ Returns the result of rotating this vector by [param angle] (in radians). See also [method @GlobalScope.deg_to_rad].
</description>
</method>
<method name="round" qualifiers="const">
@@ -340,7 +340,7 @@
<method name="sign" qualifiers="const">
<return type="Vector2" />
<description>
- Returns a new vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component.
+ Returns a new vector with each component set to [code]1.0[/code] if it's positive, [code]-1.0[/code] if it's negative, and [code]0.0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
</description>
</method>
<method name="slerp" qualifiers="const">
@@ -356,14 +356,14 @@
<return type="Vector2" />
<param index="0" name="n" type="Vector2" />
<description>
- Returns this vector slid along a plane defined by the given normal.
+ Returns the result of sliding the vector along a plane defined by the given normal.
</description>
</method>
<method name="snapped" qualifiers="const">
<return type="Vector2" />
<param index="0" name="step" type="Vector2" />
<description>
- Returns this vector with each component snapped to the nearest multiple of [param step]. This can also be used to round to an arbitrary number of decimals.
+ Returns a new vector with each component snapped to the nearest multiple of the corresponding component in [param step]. This can also be used to round the components to an arbitrary number of decimals.
</description>
</method>
</methods>
diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml
index fd02e3c530..db6bc8f237 100644
--- a/doc/classes/Vector2i.xml
+++ b/doc/classes/Vector2i.xml
@@ -92,7 +92,14 @@
<method name="sign" qualifiers="const">
<return type="Vector2i" />
<description>
- Returns a new vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component.
+ Returns a new vector with each component set to [code]1[/code] if it's positive, [code]-1[/code] if it's negative, and [code]0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
+ </description>
+ </method>
+ <method name="snapped" qualifiers="const">
+ <return type="Vector2i" />
+ <param index="0" name="step" type="Vector2i" />
+ <description>
+ Returns a new vector with each component snapped to the closest multiple of the corresponding component in [param step].
</description>
</method>
</methods>
diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml
index f075915a9c..2896408505 100644
--- a/doc/classes/Vector3.xml
+++ b/doc/classes/Vector3.xml
@@ -298,14 +298,14 @@
<return type="Vector3" />
<param index="0" name="b" type="Vector3" />
<description>
- Returns this vector projected onto the vector [param b].
+ Returns the result of projecting the vector onto the given vector [param b].
</description>
</method>
<method name="reflect" qualifiers="const">
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
- Returns this vector reflected from a plane defined by the given normal.
+ Returns the result of reflecting the vector from a plane defined by the given normal [param n].
</description>
</method>
<method name="rotated" qualifiers="const">
@@ -313,7 +313,7 @@
<param index="0" name="axis" type="Vector3" />
<param index="1" name="angle" type="float" />
<description>
- Rotates this vector around a given axis by [param angle] (in radians). The axis must be a normalized vector.
+ Returns the result of rotating this vector around a given axis by [param angle] (in radians). The axis must be a normalized vector. See also [method @GlobalScope.deg_to_rad].
</description>
</method>
<method name="round" qualifiers="const">
@@ -325,7 +325,7 @@
<method name="sign" qualifiers="const">
<return type="Vector3" />
<description>
- Returns a new vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component.
+ Returns a new vector with each component set to [code]1.0[/code] if it's positive, [code]-1.0[/code] if it's negative, and [code]0.0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
</description>
</method>
<method name="signed_angle_to" qualifiers="const">
@@ -349,14 +349,14 @@
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
- Returns this vector slid along a plane defined by the given normal.
+ Returns a new vector slid along a plane defined by the given normal.
</description>
</method>
<method name="snapped" qualifiers="const">
<return type="Vector3" />
<param index="0" name="step" type="Vector3" />
<description>
- Returns this vector with each component snapped to the nearest multiple of [param step]. This can also be used to round to an arbitrary number of decimals.
+ Returns a new vector with each component snapped to the nearest multiple of the corresponding component in [param step]. This can also be used to round the components to an arbitrary number of decimals.
</description>
</method>
</methods>
diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml
index eb64e098ce..5c6dc3c1c5 100644
--- a/doc/classes/Vector3i.xml
+++ b/doc/classes/Vector3i.xml
@@ -87,7 +87,14 @@
<method name="sign" qualifiers="const">
<return type="Vector3i" />
<description>
- Returns the vector with each component set to one or negative one, depending on the signs of the components.
+ Returns a new vector with each component set to [code]1[/code] if it's positive, [code]-1[/code] if it's negative, and [code]0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
+ </description>
+ </method>
+ <method name="snapped" qualifiers="const">
+ <return type="Vector3i" />
+ <param index="0" name="step" type="Vector3i" />
+ <description>
+ Returns a new vector with each component snapped to the closest multiple of the corresponding component in [param step].
</description>
</method>
</methods>
diff --git a/doc/classes/Vector4.xml b/doc/classes/Vector4.xml
index a2759937c1..d15ae35b59 100644
--- a/doc/classes/Vector4.xml
+++ b/doc/classes/Vector4.xml
@@ -190,21 +190,21 @@
<method name="normalized" qualifiers="const">
<return type="Vector4" />
<description>
- Returns the vector scaled to unit length. Equivalent to [code]v / v.length()[/code].
+ Returns the result of scaling the vector to unit length. Equivalent to [code]v / v.length()[/code].
</description>
</method>
<method name="posmod" qualifiers="const">
<return type="Vector4" />
<param index="0" name="mod" type="float" />
<description>
- Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod].
+ Returns a new vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod].
</description>
</method>
<method name="posmodv" qualifiers="const">
<return type="Vector4" />
<param index="0" name="modv" type="Vector4" />
<description>
- Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components.
+ Returns a new vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components.
</description>
</method>
<method name="round" qualifiers="const">
@@ -216,14 +216,14 @@
<method name="sign" qualifiers="const">
<return type="Vector4" />
<description>
- Returns a new vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component.
+ Returns a new vector with each component set to [code]1.0[/code] if it's positive, [code]-1.0[/code] if it's negative, and [code]0.0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
</description>
</method>
<method name="snapped" qualifiers="const">
<return type="Vector4" />
<param index="0" name="step" type="Vector4" />
<description>
- Returns this vector with each component snapped to the nearest multiple of [param step]. This can also be used to round to an arbitrary number of decimals.
+ Returns a new vector with each component snapped to the nearest multiple of the corresponding component in [param step]. This can also be used to round the components to an arbitrary number of decimals.
</description>
</method>
</methods>
diff --git a/doc/classes/Vector4i.xml b/doc/classes/Vector4i.xml
index 2dc10234ee..95797df90a 100644
--- a/doc/classes/Vector4i.xml
+++ b/doc/classes/Vector4i.xml
@@ -83,7 +83,14 @@
<method name="sign" qualifiers="const">
<return type="Vector4i" />
<description>
- Returns a new vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component.
+ Returns a new vector with each component set to [code]1[/code] if it's positive, [code]-1[/code] if it's negative, and [code]0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
+ </description>
+ </method>
+ <method name="snapped" qualifiers="const">
+ <return type="Vector4i" />
+ <param index="0" name="step" type="Vector4i" />
+ <description>
+ Returns a new vector with each component snapped to the closest multiple of the corresponding component in [param step].
</description>
</method>
</methods>