From ae1edee8897f2269259df6a15b0775476de71565 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 11 Nov 2020 17:54:18 -0500 Subject: [PATCH] Remove Color Static Variables Fixes #78 --- README.md | 9 ++-- examples/core/core_basic_window.cpp | 2 +- examples/models/models_billboard.cpp | 2 +- examples/shapes/shapes_logo_raylib.cpp | 2 +- examples/text/text_font_spritefont.cpp | 2 +- examples/textures/textures_bunnymark.cpp | 2 +- include/Color.hpp | 53 ------------------------ include/raylib-cpp.hpp | 2 +- tests/raylib_test.cpp | 2 - 9 files changed, 9 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 7ae1ada..052bc61 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ int main() { { BeginDrawing(); - raylib::Color::RayWhite.ClearBackground(); + ClearBackground(RAYWHITE); DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); @@ -69,10 +69,7 @@ DrawPixelV(position, PURPLE); // raylib-cpp raylib::Vector2 position(50, 50); -position.DrawPixel(raylib::Color::Purple); - -// ... or -raylib::Color::Purple.DrawPixel(position); +position.DrawPixel(PURPLE); ``` ### Method Names @@ -133,7 +130,7 @@ Vector2 position = {50.0f, 50.0f}; DrawPixelV(position, color); // Extra V in method name. // raylib-cpp -raylib::Color color = raylib::Color::Gray; +raylib::Color color = GRAY; color.DrawPixel(50, 50); Vector2 position(50.0f, 50.0f); color.DrawPixel(position); // No more V in method name. diff --git a/examples/core/core_basic_window.cpp b/examples/core/core_basic_window.cpp index b02b3c7..25823cb 100644 --- a/examples/core/core_basic_window.cpp +++ b/examples/core/core_basic_window.cpp @@ -44,7 +44,7 @@ int main() { //---------------------------------------------------------------------------------- BeginDrawing(); - raylib::Color::RayWhite.ClearBackground(); + ClearBackground(RAYWHITE); textColor.DrawText("Congrats! You created your first window!", 190, 200, 20); diff --git a/examples/models/models_billboard.cpp b/examples/models/models_billboard.cpp index c5e8274..86ac742 100644 --- a/examples/models/models_billboard.cpp +++ b/examples/models/models_billboard.cpp @@ -48,7 +48,7 @@ int main() { //---------------------------------------------------------------------------------- BeginDrawing(); - raylib::Color::RayWhite.ClearBackground(); + ClearBackground(RAYWHITE); camera.BeginMode3D(); diff --git a/examples/shapes/shapes_logo_raylib.cpp b/examples/shapes/shapes_logo_raylib.cpp index f635ec0..9aa19cc 100644 --- a/examples/shapes/shapes_logo_raylib.cpp +++ b/examples/shapes/shapes_logo_raylib.cpp @@ -19,7 +19,7 @@ int main() { raylib::Window w(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); raylib::Color foreground = raylib::Color(0, 68, 130); - raylib::Color background = raylib::Color::RayWhite; + raylib::Color background = RAYWHITE; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_font_spritefont.cpp b/examples/text/text_font_spritefont.cpp index efe39fb..a2ea4b0 100644 --- a/examples/text/text_font_spritefont.cpp +++ b/examples/text/text_font_spritefont.cpp @@ -55,7 +55,7 @@ int main(void) //---------------------------------------------------------------------------------- BeginDrawing(); - raylib::Color::RayWhite.ClearBackground(); + ClearBackground(RAYWHITE); font1.DrawText(msg1, fontPosition1, font1.baseSize, -3); font2.DrawText(msg2, fontPosition2, font2.baseSize, -2); diff --git a/examples/textures/textures_bunnymark.cpp b/examples/textures/textures_bunnymark.cpp index fa439c0..5555870 100644 --- a/examples/textures/textures_bunnymark.cpp +++ b/examples/textures/textures_bunnymark.cpp @@ -91,7 +91,7 @@ int main(void) //---------------------------------------------------------------------------------- BeginDrawing(); - raylib::Color::RayWhite.ClearBackground(); + ClearBackground(RAYWHITE); for (Bunny& bunny: bunnies) { // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS), diff --git a/include/Color.hpp b/include/Color.hpp index 8e420b0..f4eb036 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -66,33 +66,6 @@ class Color : public ::Color { set(::ColorFromNormalized(normalized)); } - static Color LightGray; - static Color Gray; - static Color DarkGray; - static Color Yellow; - static Color Gold; - static Color Orange; - static Color Pink; - static Color Red; - static Color Maroon; - static Color Green; - static Color Lime; - static Color DarkGreen; - static Color SkyBlue; - static Color Blue; - static Color DarkBlue; - static Color Purple; - static Color Violet; - static Color DarkPurple; - static Color Beige; - static Color Brown; - static Color DarkBrown; - static Color White; - static Color Black; - static Color Blank; - static Color Magenta; - static Color RayWhite; - int ToInt() const { return ::ColorToInt(*this); } @@ -229,32 +202,6 @@ class Color : public ::Color { } }; -inline Color Color::LightGray = ::LIGHTGRAY; -inline Color Color::Gray = ::GRAY; -inline Color Color::DarkGray = ::DARKGRAY; -inline Color Color::Yellow = ::YELLOW; -inline Color Color::Gold = ::GOLD; -inline Color Color::Orange = ::ORANGE; -inline Color Color::Pink = ::PINK; -inline Color Color::Red = ::RED; -inline Color Color::Maroon = ::MAROON; -inline Color Color::Green = ::GREEN; -inline Color Color::Lime = ::LIME; -inline Color Color::DarkGreen = ::DARKGREEN; -inline Color Color::SkyBlue = ::SKYBLUE; -inline Color Color::Blue = ::BLUE; -inline Color Color::DarkBlue = ::DARKBLUE; -inline Color Color::Purple = ::PURPLE; -inline Color Color::Violet = ::VIOLET; -inline Color Color::DarkPurple = ::DARKPURPLE; -inline Color Color::Beige = ::BEIGE; -inline Color Color::Brown = ::BROWN; -inline Color Color::DarkBrown = ::DARKBROWN; -inline Color Color::White = ::WHITE; -inline Color Color::Black = ::BLACK; -inline Color Color::Blank = ::BLANK; -inline Color Color::Magenta = ::MAGENTA; -inline Color Color::RayWhite = ::RAYWHITE; } // namespace raylib #endif // RAYLIB_CPP_INCLUDE_COLOR_HPP_ diff --git a/include/raylib-cpp.hpp b/include/raylib-cpp.hpp index 9f10fe8..ab3d47b 100644 --- a/include/raylib-cpp.hpp +++ b/include/raylib-cpp.hpp @@ -44,7 +44,7 @@ * { * BeginDrawing(); * -* raylib::Color::RayWhite.ClearBackground(); +* ClearBackground(RAYWHITE); * * DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); * diff --git a/tests/raylib_test.cpp b/tests/raylib_test.cpp index a8f0772..bb2e568 100644 --- a/tests/raylib_test.cpp +++ b/tests/raylib_test.cpp @@ -26,8 +26,6 @@ TEST_CASE("raylib_test", "[raylib_test]" ) { c = RAYWHITE; REQUIRE(c.r == RAYWHITE.r); - - REQUIRE(raylib::Color::LightGray.r == LIGHTGRAY.r); } SECTION("RayMath") {