fix: fix MTK elements' border radiuses
This commit is contained in:
@@ -726,6 +726,13 @@ inline void fill_round_rect_aa(Canvas& c, const Rect& box, int radius, Color col
|
||||
{box.x + box.w - r, box.y + box.h - r, box.x + box.w - r, box.y + box.h - r},
|
||||
};
|
||||
for (auto& cn : corners) {
|
||||
// Push the arc center a half pixel away from this corner (toward the
|
||||
// box interior). Pixel-center sampling otherwise sits half a pixel
|
||||
// closer to the center than the legacy pixel-corner test did, which
|
||||
// filled the arcs fuller and made small radii read as square. Left
|
||||
// corners share x == box.x, top corners share y == box.y.
|
||||
double cx = cn[2] + (cn[0] == box.x ? 0.5 : -0.5);
|
||||
double cy = cn[3] + (cn[1] == box.y ? 0.5 : -0.5);
|
||||
for (int yy = 0; yy < r; yy++) {
|
||||
int py = cn[1] + yy;
|
||||
for (int xx = 0; xx < r; xx++) {
|
||||
@@ -733,8 +740,8 @@ inline void fill_round_rect_aa(Canvas& c, const Rect& box, int radius, Color col
|
||||
int hits = 0;
|
||||
for (int sy = 0; sy < S; sy++)
|
||||
for (int sx = 0; sx < S; sx++) {
|
||||
double dx = (px + (sx + 0.5) / S) - cn[2];
|
||||
double dy = (py + (sy + 0.5) / S) - cn[3];
|
||||
double dx = (px + (sx + 0.5) / S) - cx;
|
||||
double dy = (py + (sy + 0.5) / S) - cy;
|
||||
if (dx * dx + dy * dy <= r2) hits++;
|
||||
}
|
||||
if (hits) aa_blend_px(c, px, py, color, hits * 255 / (S * S));
|
||||
|
||||
Reference in New Issue
Block a user