Add gfx::painter::circle() with different center & border colors
This commit is contained in:
parent
1d8ba361fc
commit
132a521b6a
2 changed files with 8 additions and 2 deletions
|
|
@ -56,6 +56,7 @@ namespace psemek::gfx
|
||||||
void triangle(math::point<float, 2> const & p0, math::point<float, 2> const & p1, math::point<float, 2> const & p2, color const & c0, color const & c1, color const & c2);
|
void triangle(math::point<float, 2> const & p0, math::point<float, 2> const & p1, math::point<float, 2> const & p2, color const & c0, color const & c1, color const & c2);
|
||||||
void rect(math::box<float, 2> const & box, color const & c);
|
void rect(math::box<float, 2> const & box, color const & c);
|
||||||
void circle(math::point<float, 2> const & center, float radius, color const & c, int quality = 24);
|
void circle(math::point<float, 2> const & center, float radius, color const & c, int quality = 24);
|
||||||
|
void circle(math::point<float, 2> const & center, float radius, color const & c0, color const & c1, int quality = 24);
|
||||||
void line(math::point<float, 2> const & p0, math::point<float, 2> const & p1, float width, color const & c, bool smooth = true);
|
void line(math::point<float, 2> const & p0, math::point<float, 2> const & p1, float width, color const & c, bool smooth = true);
|
||||||
void line(math::point<float, 2> const & p0, math::point<float, 2> const & p1, float w0, float w1, color const & c0, color const & c1, bool smooth = true);
|
void line(math::point<float, 2> const & p0, math::point<float, 2> const & p1, float w0, float w1, color const & c0, color const & c1, bool smooth = true);
|
||||||
void besier(math::point<float, 2> const & p0, math::point<float, 2> const & p1, math::point<float, 2> const & p2, float width, color const & c, int quality = 8, bool smooth = true);
|
void besier(math::point<float, 2> const & p0, math::point<float, 2> const & p1, math::point<float, 2> const & p2, float width, color const & c, int quality = 8, bool smooth = true);
|
||||||
|
|
|
||||||
|
|
@ -216,14 +216,19 @@ namespace psemek::gfx
|
||||||
}
|
}
|
||||||
|
|
||||||
void painter::circle(math::point<float, 2> const & p, float r, color const & c, int quality)
|
void painter::circle(math::point<float, 2> const & p, float r, color const & c, int quality)
|
||||||
|
{
|
||||||
|
circle(p, r, c, c, quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
void painter::circle(math::point<float, 2> const & p, float r, color const & c0, color const & c1, int quality)
|
||||||
{
|
{
|
||||||
std::uint32_t const base = impl().vertices.size();
|
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)
|
for (int i = 0; i < quality; ++i)
|
||||||
{
|
{
|
||||||
float const a = (math::pi * 2.f * i) / quality;
|
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)
|
for (int i = 0; i < quality; ++i)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue