You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Deprecated:** Use :ref:`Color.from_rgba8<class_Color_method_from_rgba8>` instead.
954
+
953
955
Returns a :ref:`Color<class_Color>` constructed from red (``r8``), green (``g8``), blue (``b8``), and optionally alpha (``a8``) integer channels, each divided by ``255.0`` for their final value. Using :ref:`Color8<class_@GDScript_method_Color8>` instead of the standard :ref:`Color<class_Color>` constructor is useful when you need to match exact color values in an :ref:`Image<class_Image>`.
Copy file name to clipboardExpand all lines: classes/class_array.rst
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -784,7 +784,7 @@ Returns the index of the **first** element in the array that causes ``method`` t
784
784
return number % 2 == 0
785
785
786
786
func _ready():
787
-
print([1, 3, 4, 7].find_custom(is_even.bind())) # prints 2
787
+
print([1, 3, 4, 7].find_custom(is_even.bind())) # Prints 2
788
788
789
789
790
790
@@ -1172,10 +1172,10 @@ If :ref:`max<class_Array_method_max>` is not desirable, this method may also be
1172
1172
::
1173
1173
1174
1174
func _ready():
1175
-
var arr = [Vector2(5, 0), Vector2(3, 4), Vector2(1, 2)]
1175
+
var arr = [Vector2i(5, 0), Vector2i(3, 4), Vector2i(1, 2)]
1176
1176
1177
1177
var longest_vec = arr.reduce(func(max, vec): return vec if is_length_greater(vec, max) else max)
1178
-
print(longest_vec) # Prints Vector2(3, 4).
1178
+
print(longest_vec) # Prints (3, 4)
1179
1179
1180
1180
func is_length_greater(a, b):
1181
1181
return a.length() > b.length()
@@ -1189,11 +1189,11 @@ This method can also be used to count how many elements in an array satisfy a ce
1189
1189
1190
1190
func _ready():
1191
1191
var arr = [1, 2, 3, 4, 5]
1192
-
# Increment count if it's even, else leaves count the same.
1192
+
# If the current element is even, increment count, otherwise leave count the same.
1193
1193
var even_count = arr.reduce(func(count, next): return count + 1 if is_even(next) else count, 0)
1194
1194
print(even_count) # Prints 2
1195
1195
1196
-
See also :ref:`map<class_Array_method_map>`, :ref:`filter<class_Array_method_filter>`, :ref:`any<class_Array_method_any>` and :ref:`all<class_Array_method_all>`.
1196
+
See also :ref:`map<class_Array_method_map>`, :ref:`filter<class_Array_method_filter>`, :ref:`any<class_Array_method_any>`, and :ref:`all<class_Array_method_all>`.
Copy file name to clipboardExpand all lines: classes/class_arraymesh.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,7 +240,7 @@ The ``blend_shapes`` argument is an array of vertex data for each blend shape. E
240
240
241
241
The ``lods`` argument is a dictionary with :ref:`float<class_float>` keys and :ref:`PackedInt32Array<class_PackedInt32Array>` values. Each entry in the dictionary represents an LOD level of the surface, where the value is the :ref:`Mesh.ARRAY_INDEX<class_Mesh_constant_ARRAY_INDEX>` array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of an LOD also increases the distance that the objects has to be from the camera before the LOD is used.
242
242
243
-
The ``flags`` argument is the bitwise or of, as required: One value of :ref:`ArrayCustomFormat<enum_Mesh_ArrayCustomFormat>` left shifted by ``ARRAY_FORMAT_CUSTOMn_SHIFT`` for each custom channel in use, :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.
243
+
The ``flags`` argument is the bitwise OR of, as required: One value of :ref:`ArrayCustomFormat<enum_Mesh_ArrayCustomFormat>` left shifted by ``ARRAY_FORMAT_CUSTOMn_SHIFT`` for each custom channel in use, :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.
244
244
245
245
\ **Note:** When using indices, it is recommended to only use points, lines, or triangles.
Copy file name to clipboardExpand all lines: classes/class_basis.rst
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -598,7 +598,9 @@ Creates a new **Basis** with a rotation such that the forward axis (-Z) points t
598
598
599
599
By default, the -Z axis (camera forward) is treated as forward (implies +X is right). If ``use_model_front`` is ``true``, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the ``target`` position.
600
600
601
-
The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized<class_Basis_method_orthonormalized>`). The ``target`` and ``up`` vectors cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and cannot be parallel to each other.
601
+
The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized<class_Basis_method_orthonormalized>`).
602
+
603
+
The ``target`` and the ``up`` cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and shouldn't be colinear to avoid unintended rotation around local Z axis.
Returns a **Color** constructed from red (``r8``), green (``g8``), blue (``b8``), and optionally alpha (``a8``) integer channels, each divided by ``255.0`` for their final value.
1805
+
1806
+
::
1807
+
1808
+
var red = Color.from_rgba8(255, 0, 0) # Same as Color(1, 0, 0).
1809
+
var dark_blue = Color.from_rgba8(0, 0, 51) # Same as Color(0, 0, 0.2).
1810
+
var my_color = Color.from_rgba8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4).
1811
+
1812
+
\ **Note:** Due to the lower precision of :ref:`from_rgba8<class_Color_method_from_rgba8>` compared to the standard **Color** constructor, a color created with :ref:`from_rgba8<class_Color_method_from_rgba8>` will generally not be equal to the same color created with the standard **Color** constructor. Use :ref:`is_equal_approx<class_Color_method_is_equal_approx>` for comparisons to avoid issues with floating-point precision error.
0 commit comments