瀏覽代碼

mono: New Color methods: Darkened, Lightened and ToRgba32

Kelly Thomas 7 年之前
父節點
當前提交
88bd33f451
共有 1 個文件被更改,包括 22 次插入4 次删除
  1. 22 4
      modules/mono/glue/cs_files/Color.cs

+ 22 - 4
modules/mono/glue/cs_files/Color.cs

@@ -249,6 +249,15 @@ namespace Godot
             );
             );
         }
         }
 
 
+        public Color Darkened(float amount)
+        {
+            Color res = this;
+            res.r = res.r * (1.0f - amount);
+            res.g = res.g * (1.0f - amount);
+            res.b = res.b * (1.0f - amount);
+            return res;
+        }
+
         public float Gray()
         public float Gray()
         {
         {
             return (r + g + b) / 3.0f;
             return (r + g + b) / 3.0f;
@@ -263,6 +272,15 @@ namespace Godot
             );
             );
         }
         }
 
 
+        public Color Lightened(float amount)
+        {
+            Color res = this;
+            res.r = res.r + (1.0f - res.r) * amount;
+            res.g = res.g + (1.0f - res.g) * amount;
+            res.b = res.b + (1.0f - res.b) * amount;
+            return res;
+        }
+
         public Color LinearInterpolate(Color c, float t)
         public Color LinearInterpolate(Color c, float t)
         {
         {
             var res = this;
             var res = this;
@@ -275,15 +293,15 @@ namespace Godot
             return res;
             return res;
         }
         }
 
 
-        public int To32()
+        public int ToRgba32()
         {
         {
-            int c = (byte)(a * 255);
-            c <<= 8;
-            c |= (byte)(r * 255);
+            int c = (byte)(r * 255);
             c <<= 8;
             c <<= 8;
             c |= (byte)(g * 255);
             c |= (byte)(g * 255);
             c <<= 8;
             c <<= 8;
             c |= (byte)(b * 255);
             c |= (byte)(b * 255);
+            c <<= 8;
+            c |= (byte)(a * 255);
 
 
             return c;
             return c;
         }
         }