Преглед на файлове

Merge pull request #55 from Kapendev/master

Changed the Color struct.
Steven Schveighoffer преди 1 година
родител
ревизия
7da8a5d35a
променени са 4 файла, в които са добавени 36 реда и са изтрити 12 реда
  1. 1 1
      generating.md
  2. 4 4
      source/raygui.d
  3. 5 7
      source/raylib/package.d
  4. 26 0
      source/raylib/raylib_types.d

+ 1 - 1
generating.md

@@ -14,7 +14,7 @@ Run the following command from the `raylib/src` directory. Note: path/to/raylib-
 
 ```
 dstep raylib.h raymath.h rlgl.h rcamera.h -o path/to/raylib-d/source/raylib --space-after-function-name=false \
-    --skip Vector2 --skip Vector3 --skip Vector4 --skip Quaternion --skip Matrix --skip Rectangle \
+    --skip Vector2 --skip Vector3 --skip Vector4 --skip Quaternion --skip Matrix --skip Rectangle --skip Color \
     --skip RL_MALLOC --skip RL_CALLOC --skip RL_REALLOC --skip RL_FREE
 ```
 

+ 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
     //--------------------------------------------------------------------

+ 5 - 7
source/raylib/package.d

@@ -174,13 +174,11 @@ extern (D) auto CLITERAL(T)(auto ref T type)
 // Matrix fourth row (4 components)
 
 // Color, 4 components, R8G8B8A8 (32bit)
-struct Color
-{
-    ubyte r; // Color red value
-    ubyte g; // Color green value
-    ubyte b; // Color blue value
-    ubyte a; // Color alpha value
-}
+
+// Color red value
+// Color green value
+// Color blue value
+// Color alpha value
 
 // Rectangle, 4 components
 

+ 26 - 0
source/raylib/raylib_types.d

@@ -104,6 +104,32 @@ struct Rectangle
     }
 }
 
+// Color type, R8G8B8A8 (32bit)
+struct Color
+{
+    ubyte r;
+    ubyte g;
+    ubyte b;
+    ubyte a = 255;
+
+    @safe @nogc nothrow:
+
+    this(ubyte r, ubyte g, ubyte b, ubyte a = 255) {
+        this.r = r;
+        this.g = g;
+        this.b = b;
+        this.a = a;
+    }
+
+    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);
+    }
+}
+
 enum Colors
 {
     // Some Basic Colors