Fix path rects
This commit is contained in:
@@ -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))));
|
||||||
|
|||||||
Reference in New Issue
Block a user