fix: fix MTK elements' border radiuses

This commit is contained in:
2026-07-18 10:10:56 +02:00
parent 3dea1ee6d5
commit 16d7321484
2 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once #pragma once
#define MONTAUK_BUILD_NUMBER 32 #define MONTAUK_BUILD_NUMBER 33
+9 -2
View File
@@ -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}, {box.x + box.w - r, box.y + box.h - r, box.x + box.w - r, box.y + box.h - r},
}; };
for (auto& cn : corners) { 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++) { for (int yy = 0; yy < r; yy++) {
int py = cn[1] + yy; int py = cn[1] + yy;
for (int xx = 0; xx < r; xx++) { 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; int hits = 0;
for (int sy = 0; sy < S; sy++) for (int sy = 0; sy < S; sy++)
for (int sx = 0; sx < S; sx++) { for (int sx = 0; sx < S; sx++) {
double dx = (px + (sx + 0.5) / S) - cn[2]; double dx = (px + (sx + 0.5) / S) - cx;
double dy = (py + (sy + 0.5) / S) - cn[3]; double dy = (py + (sy + 0.5) / S) - cy;
if (dx * dx + dy * dy <= r2) hits++; if (dx * dx + dy * dy <= r2) hits++;
} }
if (hits) aa_blend_px(c, px, py, color, hits * 255 / (S * S)); if (hits) aa_blend_px(c, px, py, color, hits * 255 / (S * S));