Kaynağa Gözat

Changed the Color struct.

Kapendev 1 yıl önce
ebeveyn
işleme
725cad2fd3
2 değiştirilmiş dosya ile 35 ekleme ve 5 silme
  1. 4 4
      source/raygui.d
  2. 31 1
      source/raylib/package.d

+ 4 - 4
source/raygui.d

@@ -2717,8 +2717,8 @@ int GuiListViewEx(Rectangle bounds, const(char)** text, int count, int* focus, i
 // Color Panel control
 Color GuiColorPanel(Rectangle bounds, const(char)* text, Color color)
 {
-    const(Color) colWhite = { 255, 255, 255, 255 };
-    const(Color) colBlack = { 0, 0, 0, 255 };
+    const(Color) colWhite = Color( 255, 255, 255, 255 );
+    const(Color) colBlack = Color( 0, 0, 0, 255 );
 
     GuiState state = guiState;
     Vector2 pickerSelector; // = { 0 };
@@ -2732,9 +2732,9 @@ Color GuiColorPanel(Rectangle bounds, const(char)* text, Color color)
     float hue = -1.0f;
     Vector3 maxHue = { hue >= 0.0f ? hue : hsv.x, 1.0f, 1.0f };
     Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
-    Color maxHueCol = { cast(ubyte)(255.0f*rgbHue.x),
+    Color maxHueCol = Color( cast(ubyte)(255.0f*rgbHue.x),
                       cast(ubyte)(255.0f*rgbHue.y),
-                      cast(ubyte)(255.0f*rgbHue.z), 255 };
+                      cast(ubyte)(255.0f*rgbHue.z), 255 );
 
     // Update control
     //--------------------------------------------------------------------

+ 31 - 1
source/raylib/package.d

@@ -179,7 +179,37 @@ struct Color
     ubyte r; // Color red value
     ubyte g; // Color green value
     ubyte b; // Color blue value
-    ubyte a; // Color alpha value
+    ubyte a = 255; // Color alpha value
+
+    @safe @nogc nothrow:
+
+    this(ubyte r, ubyte g, ubyte b, ubyte a) {
+        this.r = r;
+        this.g = g;
+        this.b = b;
+        this.a = a;
+    }
+
+    this(ubyte r, ubyte g, ubyte b) {
+        this(r, g, b, 255);
+    }
+
+    this(ubyte[4] rgba) {
+        this(rgba[0], rgba[1], rgba[2], rgba[3]);
+    }
+
+    this(ubyte[3] rgb) {
+        this(rgb[0], rgb[1], rgb[2], 255);
+    }
+
+    this(uint rgba) {
+        this(
+            (rgba & 0xFF000000) >> 24,
+            (rgba & 0xFF0000) >> 16,
+            (rgba & 0xFF00) >> 8,
+            (rgba & 0xFF),
+        );
+    }
 }
 
 // Rectangle, 4 components