raylib_types.d 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /// This module defines basic types from Raylib with local modifications to make them easier to use.
  2. module raylib_types;
  3. import raylib;
  4. // Vector2 type
  5. struct Vector2
  6. {
  7. float x = 0.0f;
  8. float y = 0.0f;
  9. mixin Linear;
  10. }
  11. // Vector3 type
  12. struct Vector3
  13. {
  14. float x = 0.0f;
  15. float y = 0.0f;
  16. float z = 0.0f;
  17. mixin Linear;
  18. }
  19. // Vector4 type
  20. struct Vector4
  21. {
  22. float x = 0.0f;
  23. float y = 0.0f;
  24. float z = 0.0f;
  25. float w = 0.0f;
  26. mixin Linear;
  27. }
  28. // Quaternion type, same as Vector4
  29. alias Quaternion = Vector4;
  30. // Matrix type (OpenGL style 4x4 - right handed, column major)
  31. struct Matrix
  32. {
  33. float m0 = 0.0f;
  34. float m4 = 0.0f;
  35. float m8 = 0.0f;
  36. float m12 = 0.0f;
  37. float m1 = 0.0f;
  38. float m5 = 0.0f;
  39. float m9 = 0.0f;
  40. float m13 = 0.0f;
  41. float m2 = 0.0f;
  42. float m6 = 0.0f;
  43. float m10 = 0.0f;
  44. float m14 = 0.0f;
  45. float m3 = 0.0f;
  46. float m7 = 0.0f;
  47. float m11 = 0.0f;
  48. float m15 = 0.0f;
  49. }
  50. // Rectangle type
  51. struct Rectangle
  52. {
  53. float x;
  54. float y;
  55. float width;
  56. float height;
  57. alias w = width;
  58. alias h = height;
  59. }
  60. enum Colors
  61. {
  62. // Some Basic Colors
  63. // NOTE: Custom raylib color palette for amazing visuals on WHITE background
  64. LIGHTGRAY = Color(200, 200, 200, 255), // Light Gray
  65. GRAY = Color(130, 130, 130, 255), // Gray
  66. DARKGRAY = Color(80, 80, 80, 255), // Dark Gray
  67. YELLOW = Color(253, 249, 0, 255), // Yellow
  68. GOLD = Color(255, 203, 0, 255), // Gold
  69. ORANGE = Color(255, 161, 0, 255), // Orange
  70. PINK = Color(255, 109, 194, 255), // Pink
  71. RED = Color(230, 41, 55, 255), // Red
  72. MAROON = Color(190, 33, 55, 255), // Maroon
  73. GREEN = Color(0, 228, 48, 255), // Green
  74. LIME = Color(0, 158, 47, 255), // Lime
  75. DARKGREEN = Color(0, 117, 44, 255), // Dark Green
  76. SKYBLUE = Color(102, 191, 255, 255), // Sky Blue
  77. BLUE = Color(0, 121, 241, 255), // Blue
  78. DARKBLUE = Color(0, 82, 172, 255), // Dark Blue
  79. PURPLE = Color(200, 122, 255, 255), // Purple
  80. VIOLET = Color(135, 60, 190, 255), // Violet
  81. DARKPURPLE = Color(112, 31, 126, 255), // Dark Purple
  82. BEIGE = Color(211, 176, 131, 255), // Beige
  83. BROWN = Color(127, 106, 79, 255), // Brown
  84. DARKBROWN = Color(76, 63, 47, 255), // Dark Brown
  85. WHITE = Color(255, 255, 255, 255), // White
  86. BLACK = Color(0, 0, 0, 255), // Black
  87. BLANK = Color(0, 0, 0, 0), // Blank (Transparent)
  88. MAGENTA = Color(255, 0, 255, 255), // Magenta
  89. RAYWHITE = Color(245, 245, 245, 255), // My own White (raylib logo)
  90. }