Table of Contents

Class RoundedRect

Namespace
Xui.Core.Canvas
Assembly
Xui.Core.dll

Utility for clamping corner radii to fit within a rectangle, following the CSS Backgrounds and Borders Module Level 3, Section 5.5 "Overlapping Curves". When the sum of adjacent radii exceeds a side's length, all radii are scaled down proportionally so that curves never overlap.

public static class RoundedRect
Inheritance
RoundedRect
Inherited Members

Methods

Clamp(Size, NFloat)

Returns a uniform radius clamped to fit within the given size. Equivalent to min(radius, width / 2, height / 2).

public static NFloat Clamp(Size size, NFloat radius)

Parameters

size Size

The dimensions of the rectangle.

radius NFloat

The desired uniform corner radius.

Returns

NFloat

The clamped radius value.

Clamp(Size, CornerRadius)

Returns a CornerRadius whose values are clamped so that adjacent corners do not overlap on any side of a rectangle of the given size.

Algorithm: compute f = min(1, L_i / S_i) over all four sides, where L_i is the side length and S_i is the sum of the two corner radii on that side. Then multiply every radius by f.

public static CornerRadius Clamp(Size size, CornerRadius radius)

Parameters

size Size

The dimensions of the rectangle.

radius CornerRadius

The desired corner radii.

Returns

CornerRadius

Corner radii scaled to fit within the rectangle.