Skip to main content

sd_rounded_rect

Function sd_rounded_rect 

Source
pub fn sd_rounded_rect(
    px: f32,
    py: f32,
    half_w: f32,
    half_h: f32,
    r: f32,
) -> f32
Expand description

Analytical Signed Distance Field for a rounded rectangle.

Mathematical formula: Given point p relative to center of box with half-extents b and corner radius r: q = |p| - b + r d = length(max(q, 0)) + min(max(q.x, q.y), 0) - r