Fix path rects

This commit is contained in:
2026-03-29 04:27:37 +02:00
parent 818b086f08
commit 4498c2c0fb
+8 -8
View File
@@ -68,15 +68,15 @@ PD_API void Drawlist::PathFastArcToN(const fvec2& c, float r, float amin,
} }
} }
PD_API void Drawlist::PathRect(const fvec2& tl, const fvec2& br, float r) { PD_API void Drawlist::PathRect(const fvec2& tl, const fvec2& br,
if (r == 0.f) { float rounding) {
if (rounding == 0.f) {
PathAdd(tl); PathAdd(tl);
PathAdd(vec2(br.x, tl.y)); PathAdd(vec2(br.x, tl.y));
PathAdd(br); PathAdd(br);
PathAdd(vec2(tl.x, br.y)); PathAdd(vec2(tl.x, br.y));
} else { } else {
float r = std::numeric_limits<float>::max(); float r = std::min({rounding, (br.x - tl.x) * 0.5f, (br.y - tl.y) * 0.5f});
r = std::min({r, (br.x - tl.x) * 0.5f, (br.y - tl.y) * 0.5f});
/** Calculate Optimal segment count automatically */ /** Calculate Optimal segment count automatically */
float corner = M_PI * 0.5f; float corner = M_PI * 0.5f;
int segments = std::max(3, int(std::ceil(corner / (6.0f * M_PI / 180.0f)))); int segments = std::max(3, int(std::ceil(corner / (6.0f * M_PI / 180.0f))));
@@ -101,15 +101,15 @@ PD_API void Drawlist::PathRect(const fvec2& tl, const fvec2& br, float r) {
} }
} }
PD_API void Drawlist::PathRectEx(const fvec2& tl, const fvec2& br, float r, PD_API void Drawlist::PathRectEx(const fvec2& tl, const fvec2& br,
LiPathRectFlags flags) { float rounding, LiPathRectFlags flags) {
if (r == 0.f) { if (rounding == 0.f) {
PathAdd(tl); PathAdd(tl);
PathAdd(vec2(br.x, tl.y)); PathAdd(vec2(br.x, tl.y));
PathAdd(br); PathAdd(br);
PathAdd(vec2(tl.x, br.y)); PathAdd(vec2(tl.x, br.y));
} else { } else {
float r = std::min({r, (br.x - tl.x) * 0.5f, (br.y - tl.y) * 0.5f}); float r = std::min({rounding, (br.x - tl.x) * 0.5f, (br.y - tl.y) * 0.5f});
/** Calculate Optimal segment count automatically */ /** Calculate Optimal segment count automatically */
float corner = M_PI * 0.5f; float corner = M_PI * 0.5f;
int segments = std::max(3, int(std::ceil(corner / (6.0f * M_PI / 180.0f)))); int segments = std::max(3, int(std::ceil(corner / (6.0f * M_PI / 180.0f))));