浏览代码

Expose 64-bit Color methods to GDScript and fix/update Color XML doc

Aaron Franke 7 年之前
父节点
当前提交
55d976467d
共有 2 个文件被更改,包括 67 次插入16 次删除
  1. 10 2
      core/variant_call.cpp
  2. 57 14
      doc/classes/Color.xml

+ 10 - 2
core/variant_call.cpp

@@ -446,8 +446,12 @@ struct _VariantCall {
 	VCALL_LOCALMEM1(Quat, set_euler);
 	VCALL_LOCALMEM2(Quat, set_axis_angle);
 
-	VCALL_LOCALMEM0R(Color, to_rgba32);
 	VCALL_LOCALMEM0R(Color, to_argb32);
+	VCALL_LOCALMEM0R(Color, to_abgr32);
+	VCALL_LOCALMEM0R(Color, to_rgba32);
+	VCALL_LOCALMEM0R(Color, to_argb64);
+	VCALL_LOCALMEM0R(Color, to_abgr64);
+	VCALL_LOCALMEM0R(Color, to_rgba64);
 	VCALL_LOCALMEM0R(Color, gray);
 	VCALL_LOCALMEM0R(Color, inverted);
 	VCALL_LOCALMEM0R(Color, contrasted);
@@ -1613,8 +1617,12 @@ void register_variant_methods() {
 	ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray());
 	ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
 
-	ADDFUNC0R(COLOR, INT, Color, to_rgba32, varray());
 	ADDFUNC0R(COLOR, INT, Color, to_argb32, varray());
+	ADDFUNC0R(COLOR, INT, Color, to_abgr32, varray());
+	ADDFUNC0R(COLOR, INT, Color, to_rgba32, varray());
+	ADDFUNC0R(COLOR, INT, Color, to_argb64, varray());
+	ADDFUNC0R(COLOR, INT, Color, to_abgr64, varray());
+	ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray());
 	ADDFUNC0R(COLOR, REAL, Color, gray, varray());
 	ADDFUNC0R(COLOR, COLOR, Color, inverted, varray());
 	ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());

+ 57 - 14
doc/classes/Color.xml

@@ -187,17 +187,6 @@
 				[/codeblock]
 			</description>
 		</method>
-		<method name="to_argb32">
-			<return type="int">
-			</return>
-			<description>
-				Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile). More compatible with DirectX.
-				[codeblock]
-				var c = Color(1, .5, .2)
-				print(str(c.to_32())) # prints 4294934323
-				[/codeblock]
-			</description>
-		</method>
 		<method name="to_html">
 			<return type="String">
 			</return>
@@ -213,16 +202,70 @@
 				[/codeblock]
 			</description>
 		</method>
+		<method name="to_argb32">
+			<return type="int">
+			</return>
+			<description>
+				Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile). ARGB is more compatible with DirectX.
+				[codeblock]
+				var c = Color(1, .5, .2)
+				print(c.to_argb32()) # Prints 4294934323
+				[/codeblock]
+			</description>
+		</method>
+		<method name="to_abgr32">
+			<return type="int">
+			</return>
+			<description>
+				Returns the color's 32-bit integer in ABGR format (each byte represents a component of the ABGR profile). ABGR is the reversed version of the default format.
+				[codeblock]
+				var c = Color(1, .5, .2)
+				print(c.to_abgr32()) # Prints 4281565439
+				[/codeblock]
+			</description>
+		</method>
 		<method name="to_rgba32">
 			<return type="int">
 			</return>
 			<description>
-				Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile).
+				Returns the color's 32-bit integer in RGBA format (each byte represents a component of the RGBA profile). RGBA is the format that Godot uses by default.
+				[codeblock]
+				var c = Color(1, .5, .2)
+				print(c.to_rgba32()) # Prints 4286526463
+				[/codeblock]
+			</description>
+		</method>
+		<method name="to_argb64">
+			<return type="int">
+			</return>
+			<description>
+				Returns the color's 64-bit integer in ARGB format (each word represents a component of the ARGB profile). ARGB is more compatible with DirectX.
+				[codeblock]
+				var c = Color(1, .5, .2)
+				print(c.to_argb64()) # Prints -2147470541
+				[/codeblock]
+			</description>
+		</method>
+		<method name="to_abgr64">
+			<return type="int">
+			</return>
+			<description>
+				Returns the color's 64-bit integer in ABGR format (each word represents a component of the ABGR profile). ABGR is the reversed version of the default format.
+				[codeblock]
+				var c = Color(1, .5, .2)
+				print(c.to_abgr64()) # Prints -225178692812801
+				[/codeblock]
+			</description>
+		</method>
+		<method name="to_rgba64">
+			<return type="int">
+			</return>
+			<description>
+				Returns the color's 64-bit integer in RGBA format (each word represents a component of the RGBA profile). RGBA is the format that Godot uses by default.
 				[codeblock]
 				var c = Color(1, .5, .2)
-				print(str(c.to_32())) # prints 4294934323
+				print(c.to_rgba64()) # Prints -140736629309441
 				[/codeblock]
-				[i]This is same as [method to_argb32] but may be changed later to support RGBA format instead[/i].
 			</description>
 		</method>
 	</methods>