diff --git a/libs/gfx/include/psemek/gfx/painter.hpp b/libs/gfx/include/psemek/gfx/painter.hpp index edf12ffe..d3e26152 100644 --- a/libs/gfx/include/psemek/gfx/painter.hpp +++ b/libs/gfx/include/psemek/gfx/painter.hpp @@ -57,6 +57,7 @@ namespace psemek::gfx void rect(geom::box const & box, color const & c); void circle(geom::point const & center, float radius, color const & c, int quality = 24); void line(geom::point const & p0, geom::point const & p1, float width, color const & c, bool smooth = true); + void line(geom::point const & p0, geom::point const & p1, float width, color const & c0, color const & c1, bool smooth = true); void besier(geom::point const & p0, geom::point const & p1, geom::point const & p2, float width, color const & c, int quality = 8, bool smooth = true); // 2D text diff --git a/libs/gfx/source/painter.cpp b/libs/gfx/source/painter.cpp index 2aead2b1..d13f7e94 100644 --- a/libs/gfx/source/painter.cpp +++ b/libs/gfx/source/painter.cpp @@ -238,6 +238,11 @@ namespace psemek::gfx } void painter::line(geom::point const & p0, geom::point const & p1, float width, color const & c, bool smooth) + { + line(p0, p1, width, c, c, smooth); + } + + void painter::line(geom::point const & p0, geom::point const & p1, float width, color const & c0, color const & c1, bool smooth) { std::uint32_t const base = impl().vertices.size(); float const r = width / 2.f; @@ -245,10 +250,10 @@ namespace psemek::gfx auto const d = geom::normalized(p1 - p0); geom::vector const o { -d[1], d[0] }; - impl().vertices.push_back({{p0[0] + r * o[0], p0[1] + r * o[1], 0.f}, c}); - impl().vertices.push_back({{p0[0] - r * o[0], p0[1] - r * o[1], 0.f}, c}); - impl().vertices.push_back({{p1[0] + r * o[0], p1[1] + r * o[1], 0.f}, c}); - impl().vertices.push_back({{p1[0] - r * o[0], p1[1] - r * o[1], 0.f}, c}); + impl().vertices.push_back({{p0[0] + r * o[0], p0[1] + r * o[1], 0.f}, c0}); + impl().vertices.push_back({{p0[0] - r * o[0], p0[1] - r * o[1], 0.f}, c0}); + impl().vertices.push_back({{p1[0] + r * o[0], p1[1] + r * o[1], 0.f}, c1}); + impl().vertices.push_back({{p1[0] - r * o[0], p1[1] - r * o[1], 0.f}, c1}); impl().indices.push_back(base + 0); impl().indices.push_back(base + 1); @@ -259,8 +264,8 @@ namespace psemek::gfx if (smooth) { - circle(p0, r, c); - circle(p1, r, c); + circle(p0, r, c0); + circle(p1, r, c1); } }