From 53e2fab582c39aebdced23a45182f34d3b11da4f Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 19 Mar 2023 13:43:04 -0600 Subject: [PATCH] Prefer named colors --- include/SFML/Graphics/Image.hpp | 2 +- include/SFML/Graphics/RenderTarget.hpp | 2 +- src/SFML/Graphics/Font.cpp | 4 ++-- test/Graphics/Image.test.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp index 933a15297..46270da79 100644 --- a/include/SFML/Graphics/Image.hpp +++ b/include/SFML/Graphics/Image.hpp @@ -55,7 +55,7 @@ public: /// \param color Fill color /// //////////////////////////////////////////////////////////// - void create(const Vector2u& size, const Color& color = Color(0, 0, 0)); + void create(const Vector2u& size, const Color& color = Color::Black); //////////////////////////////////////////////////////////// /// \brief Create the image from an array of pixels diff --git a/include/SFML/Graphics/RenderTarget.hpp b/include/SFML/Graphics/RenderTarget.hpp index fcca3b5c9..4191ab143 100644 --- a/include/SFML/Graphics/RenderTarget.hpp +++ b/include/SFML/Graphics/RenderTarget.hpp @@ -80,7 +80,7 @@ public: /// \param color Fill color to use to clear the render target /// //////////////////////////////////////////////////////////// - void clear(const Color& color = Color(0, 0, 0, 255)); + void clear(const Color& color = Color::Black); //////////////////////////////////////////////////////////// /// \brief Change the current active view diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 194a1dcbb..39b26feae 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -834,12 +834,12 @@ Font::Page::Page(bool smooth) { // Make sure that the texture is initialized by default sf::Image image; - image.create({128, 128}, Color(255, 255, 255, 0)); + image.create({128, 128}, Color::Transparent); // Reserve a 2x2 white square for texturing underlines for (unsigned int x = 0; x < 2; ++x) for (unsigned int y = 0; y < 2; ++y) - image.setPixel({x, y}, Color(255, 255, 255, 255)); + image.setPixel({x, y}, Color::White); // Create the texture if (!texture.loadFromImage(image)) diff --git a/test/Graphics/Image.test.cpp b/test/Graphics/Image.test.cpp index d6679bfb1..1855b608b 100644 --- a/test/Graphics/Image.test.cpp +++ b/test/Graphics/Image.test.cpp @@ -36,7 +36,7 @@ TEST_CASE("[Graphics] sf::Image") { for (std::uint32_t j = 0; j < 10; ++j) { - CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color(0, 0, 0)); + CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color::Black); } } } @@ -133,7 +133,7 @@ TEST_CASE("[Graphics] sf::Image") if (i <= 4 && j <= 4) CHECK(image2.getPixel(sf::Vector2u(i, j)) == sf::Color::Blue); else - CHECK(image2.getPixel(sf::Vector2u(i, j)) == sf::Color(0, 0, 0)); + CHECK(image2.getPixel(sf::Vector2u(i, j)) == sf::Color::Black); } } }