fix: support per-corner radius

also adjusts the radius by half of the outline thickness. I believe this is the radius at the center of the outline.
This commit is contained in:
Ashley Wulber 2025-09-24 17:50:23 -04:00 committed by Victoria Brekenfeld
parent b3aa10436a
commit c6320eec0c
5 changed files with 67 additions and 28 deletions

View file

@ -8,10 +8,14 @@ varying vec2 v_coords;
uniform vec3 color;
uniform float thickness;
uniform float radius;
uniform vec4 radius;
float rounded_box(vec2 center, vec2 size, float radius) {
return length(max(abs(center) - size + radius, 0.0)) - radius;
float rounded_box(in vec2 p, in vec2 b, in vec4 r)
{
r.xy = (p.x > 0.0) ? r.xy : r.zw;
r.x = (p.y > 0.0) ? r.x : r.y;
vec2 q = abs(p) - b + r.x;
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r.x;
}
void main() {