Fix rounded corner rendering issue
This commit is contained in:
parent
b6220d182c
commit
d96a1d63aa
@ -70,7 +70,6 @@ fn void ui_top_bar()
|
||||
{
|
||||
ui_push(child_layout_axis, AXIS2_X);
|
||||
auto* top_bar = ui_widget_make((UI_WidgetFlags) {
|
||||
.draw_background = 1,
|
||||
}, strlit("top_bar"));
|
||||
ui_push(parent, top_bar);
|
||||
{
|
||||
|
@ -14,8 +14,15 @@ layout(set = 0, binding = 0) uniform sampler2D textures[];
|
||||
|
||||
float rounded_rect_sdf(vec2 position, vec2 center, vec2 half_size, float radius)
|
||||
{
|
||||
vec2 d2 = abs(center - position) - half_size + vec2(radius, radius);
|
||||
float result = min(max(d2.x, d2.y), 0.0) + length(max(d2, 0.0)) - radius;
|
||||
vec2 r2 = vec2(radius, radius);
|
||||
// This is 0 when the point is at the border
|
||||
vec2 d2_no_r2 = abs(center - position) - half_size;
|
||||
vec2 d2 = d2_no_r2 + r2;
|
||||
// 0 when outside the rectangle
|
||||
float negative_euclidean_distance = min(max(d2.x, d2.y), 0.0);
|
||||
// 0 when inside the rectangle
|
||||
float positive_euclidean_distance = length(max(d2, 0.0));
|
||||
float result = negative_euclidean_distance + positive_euclidean_distance - radius;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user