# GeometryBuilder

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/struct-geometrybuilder/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct GeometryBuilder
```

Contains internal helpers used to build and draw various geometries.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/geometry_builder.rs#L14)

## Members

- [`draw_rounded_corners_rectangle_keypoints`](#function-draw_rounded_corners_rectangle_keypoints)
- [`calculate_rounded_corners_rectangle_win_ui`](#function-calculate_rounded_corners_rectangle_win_ui)

<a id="function-draw_rounded_corners_rectangle_keypoints"></a>

### draw_rounded_corners_rectangle_keypoints

```rust
fn draw_rounded_corners_rectangle_keypoints(context: &mut StreamGeometryContext, keypoints: &RoundedRectKeypoints)
```

Draws a new rounded rectangle within the given geometry context.
Warning: The caller must manage and dispose the `StreamGeometryContext` externally.

WinUI: https://github.com/microsoft/microsoft-ui-xaml/blob/93742a178db8f625ba9299f62c21f656e0b195ad/dxaml/xcp/core/core/elements/geometry.cpp#L1072-L1079

* `context` - The geometry context to draw into.
* `keypoints` - The rounded rectangle keypoints defining the rectangle to draw.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/geometry_builder.rs#L24)

<a id="function-calculate_rounded_corners_rectangle_win_ui"></a>

### calculate_rounded_corners_rectangle_win_ui

```rust
fn calculate_rounded_corners_rectangle_win_ui(outer_bounds: Rect, border_thickness: Thickness, corner_radius: CornerRadius, sizing: BackgroundSizing) -> RoundedRectKeypoints
```

Calculates the keypoints of a rounded rectangle based on the algorithm in WinUI.
These keypoints may then be drawn or transformed into other types.

* `outer_bounds` - The outer bounds of the rounded rectangle.
  This should be the overall bounds and size of the shape/control without any
  corner radii or border thickness adjustments.
* `border_thickness` - The unadjusted border thickness of the rounded rectangle.
* `corner_radius` - The unadjusted corner radii of the rounded rectangle.
  The corner radius is defined to be the middle of the border stroke (center of the border).
* `sizing` - The sizing mode used to calculate the final rounded rectangle size.

Returns new rounded rectangle keypoints.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/geometry_builder.rs#L202)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
