Skip to content

Commit

Permalink
🐞 fix: border radius
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhUyU1997 committed Jan 28, 2023
1 parent d2cddfb commit 6f076f9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/box.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,15 @@ static void draw_box_background(Box *box, plutovg_t *pluto, plutovg_rect_t *rect
float radius_other = radius[(max_index + 2) % 4];
float radius_prev = radius[(max_index + 3) % 4];

float r1 = radius_next + radius_max > w ? w * radius_max / (radius_next + radius_max) : radius_max;
float r2 = radius_prev + radius_max > w ? w * radius_max / (radius_prev + radius_max) : radius_max;
float r1_next = radius_next + radius_max;
float r2_prev = radius_prev + radius_max;
float r1_max = max_index % 2 == 0 ? w : h;
float r2_max = max_index % 2 == 0 ? h : w;

r[max_index][0] = r[max_index][1] = fmaxf(r1, r2);
float r1 = r1_next > r1_max ? (r1_max * radius_max / r1_next) : radius_max;
float r2 = r2_prev > r2_max ? (r2_max * radius_max / r2_prev) : radius_max;

r[max_index][0] = r[max_index][1] = fminf(r1, r2);
r[(max_index + 1) % 4][0] = r[(max_index + 1) % 4][1] = r[max_index][0] * radius_next / radius_max;
r[(max_index + 2) % 4][0] = r[(max_index + 2) % 4][1] = r[max_index][0] * radius_other / radius_max;
r[(max_index + 3) % 4][0] = r[(max_index + 3) % 4][1] = r[max_index][0] * radius_prev / radius_max;
Expand Down

0 comments on commit 6f076f9

Please sign in to comment.