Rounded Fill Rect
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m49s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m49s
This commit is contained in:
@@ -75,7 +75,7 @@ namespace JGL {
|
||||
void DrawString(const Color3& color, std::string text, float x, float y, float scale, u32 size, unsigned int font_index);
|
||||
void FillRect(const Color4& color, const Vector2& pos, const Vector2& size);
|
||||
void OutlineRect ( const Color4& color, const Vector2& pos, const Vector2& size, float thickness = 1);
|
||||
void FillRoundedRect (const Color4& color, const Vector2& pos, const Vector2& size, float radius);
|
||||
void RoundedFillRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius, unsigned int subdivisions);
|
||||
void OutlineRoundedRect(const Color4& color, const Vector2& pos, const Vector2& size, float radius, float thickness = 1);
|
||||
void OutlinePolygon (const Color4& color, std::vector<Vector2> points);
|
||||
void FillPolygon (const Color4& color, std::vector<Vector2> points, float thickness = 1);
|
||||
@@ -90,7 +90,8 @@ namespace JGL {
|
||||
void OutlineCircle(const Color3& color, const Vector2& center, float radius, int subdivisions, float thickness = 1);
|
||||
void FillCircle(const Color3& color, const Vector2& center, float radius, int subdivisions);
|
||||
void OutlineTriangle(const Color3& color, const Triangle2D& tri, float thickness = 1);
|
||||
void FillTriangle(const Color3& color, const Triangle2D &tri);
|
||||
void FillTriangle(const Color3& color, const Triangle2D& tri);
|
||||
void RoundedFillRect(const Color3& color, const Vector2& pos, const Vector2& size, float radius, unsigned int subdivisions);
|
||||
}
|
||||
namespace J3D {
|
||||
void Begin();
|
||||
|
4
main.cpp
4
main.cpp
@@ -104,7 +104,9 @@ public:
|
||||
|
||||
J2D::Begin();
|
||||
J2D::FillRect(JGL::Colors::Blue, {32, 32}, {100.5, 100.5});
|
||||
J2D::FillRect({255,0,0,255/2}, {100.5, 100.5}, {32, 32});
|
||||
|
||||
J2D::RoundedFillRect(JGL::Colors::Red, {256, 256}, {100.5, 100.5}, 8, 8);
|
||||
//J2D::FillRect({255,0,0,255/2}, {100.5, 100.5}, {32, 32});
|
||||
|
||||
//J2D::OutlineTriangle(JGL::Colors::Yellow, {{140, 200},{135, 100},{105, 100}});
|
||||
J2D::FillCircle(JGL::Colors::White, {120, 200}, 20, 16);
|
||||
|
16
src/JGL.cpp
16
src/JGL.cpp
@@ -87,6 +87,20 @@ namespace JGL {
|
||||
J2D::FillRect({color.r, color.g, color.b, 255}, pos, size);
|
||||
}
|
||||
|
||||
void J2D::RoundedFillRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius, unsigned int subdivisions) {
|
||||
J2D::FillRect(color, {pos.x + radius, pos.y}, {size.x - 2 * radius, size.y});
|
||||
J2D::FillRect(color, {pos.x, pos.y + radius}, {size.x, size.y - 2 * radius});
|
||||
|
||||
J2D::FillCircle(color, {pos.x + radius, pos.y + radius}, radius, subdivisions);
|
||||
J2D::FillCircle(color, {pos.x + size.x - radius, pos.y + radius}, radius, subdivisions);
|
||||
J2D::FillCircle(color, {pos.x + radius, pos.y + size.y - radius}, radius, subdivisions);
|
||||
J2D::FillCircle(color, {pos.x + size.x - radius, pos.y + size.y - radius}, radius, subdivisions);
|
||||
}
|
||||
|
||||
void J2D::RoundedFillRect(const JGL::Color3& color, const J3ML::LinearAlgebra::Vector2& pos, const J3ML::LinearAlgebra::Vector2& size, float radius, unsigned int subdivisions) {
|
||||
J2D::RoundedFillRect({color.r, color.g, color.b, 255}, pos, size, radius, subdivisions);
|
||||
}
|
||||
|
||||
void J2D::OutlineRect(const Color4& color, const Vector2& pos, const Vector2& size, float thickness) {
|
||||
Vector2 vertices[] = {{pos.x, pos.y}, {pos.x, pos.y + size.y}, {pos.x + size.x, pos.y + size.y}, {pos.x + size.x, pos.y}};
|
||||
|
||||
@@ -161,7 +175,7 @@ namespace JGL {
|
||||
void J2D::OutlineCircle(const Color3& color, const Vector2& center, float radius, int subdivisions, float thickness) {
|
||||
J2D::OutlineCircle({color.r, color.g, color.b, 255}, center, radius, subdivisions, thickness);
|
||||
}
|
||||
|
||||
|
||||
void J2D::FillCircle(const Color4& color, const Vector2& center, float radius, int subdivisions) {
|
||||
float step = (2.f * M_PI) / (float) subdivisions;;
|
||||
std::vector<Vector2> vertices{};
|
||||
|
Reference in New Issue
Block a user