From 132a521b6a97f54afec19321a4f6817315b6f1ea Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 14 May 2025 22:54:05 +0300 Subject: [PATCH] Add gfx::painter::circle() with different center & border colors --- libs/gfx/include/psemek/gfx/painter.hpp | 1 + libs/gfx/source/painter.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/gfx/include/psemek/gfx/painter.hpp b/libs/gfx/include/psemek/gfx/painter.hpp index f86c44c0..d22cbb24 100644 --- a/libs/gfx/include/psemek/gfx/painter.hpp +++ b/libs/gfx/include/psemek/gfx/painter.hpp @@ -56,6 +56,7 @@ namespace psemek::gfx void triangle(math::point const & p0, math::point const & p1, math::point const & p2, color const & c0, color const & c1, color const & c2); void rect(math::box const & box, color const & c); void circle(math::point const & center, float radius, color const & c, int quality = 24); + void circle(math::point const & center, float radius, color const & c0, color const & c1, int quality = 24); void line(math::point const & p0, math::point const & p1, float width, color const & c, bool smooth = true); void line(math::point const & p0, math::point const & p1, float w0, float w1, color const & c0, color const & c1, bool smooth = true); void besier(math::point const & p0, math::point const & p1, math::point const & p2, float width, color const & c, int quality = 8, bool smooth = true); diff --git a/libs/gfx/source/painter.cpp b/libs/gfx/source/painter.cpp index 038cc6b3..28bbac6d 100644 --- a/libs/gfx/source/painter.cpp +++ b/libs/gfx/source/painter.cpp @@ -216,14 +216,19 @@ namespace psemek::gfx } void painter::circle(math::point const & p, float r, color const & c, int quality) + { + circle(p, r, c, c, quality); + } + + void painter::circle(math::point const & p, float r, color const & c0, color const & c1, int quality) { std::uint32_t const base = impl().vertices.size(); - impl().vertices.push_back({{p[0], p[1], 0.f}, c}); + impl().vertices.push_back({{p[0], p[1], 0.f}, c0}); for (int i = 0; i < quality; ++i) { float const a = (math::pi * 2.f * i) / quality; - impl().vertices.push_back({{p[0] + r * std::cos(a), p[1] + r * std::sin(a), 0.f}, c}); + impl().vertices.push_back({{p[0] + r * std::cos(a), p[1] + r * std::sin(a), 0.f}, c1}); } for (int i = 0; i < quality; ++i)