# CompositionSurfaceBrush

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/rendering/composition/brushes/struct-compositionsurfacebrush/

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

```rust
struct CompositionSurfaceBrush
```

A composition brush that paints a surface (WinUI
`Microsoft.UI.Composition.CompositionSurfaceBrush`): a
`LoadedImageSurface`,
a `CompositionVisualSurface`
or a `CompositionSurface`.

The surface is laid out at its natural size in the area of the brush by
`stretch` and the alignment ratios, transformed by the transform of the
brush (`AnchorPoint`, `CenterPoint`, `Offset`, `RotationAngle`, `Scale`,
`TransformMatrix`, relative to the area) and clipped to the area. The
alignment ratios and the transform members are animatable.

It is painted by the visuals that show it (a sprite visual); it is not a
brush of the drawing context, so it cannot fill the shapes of a drawing
context. The `Opacity` of the composition brushes applies; their
`Transform` and `RelativeTransform` do not.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L942)

## Members

- [`from_brush`](#function-from_brush)
- [`surface`](#function-surface)
- [`set_surface`](#function-set_surface)
- [`stretch`](#function-stretch)
- [`set_stretch`](#function-set_stretch)
- [`horizontal_alignment_ratio`](#function-horizontal_alignment_ratio)
- [`set_horizontal_alignment_ratio`](#function-set_horizontal_alignment_ratio)
- [`vertical_alignment_ratio`](#function-vertical_alignment_ratio)
- [`set_vertical_alignment_ratio`](#function-set_vertical_alignment_ratio)
- [`bitmap_interpolation_mode`](#function-bitmap_interpolation_mode)
- [`set_bitmap_interpolation_mode`](#function-set_bitmap_interpolation_mode)
- [`anchor_point`](#function-anchor_point)
- [`set_anchor_point`](#function-set_anchor_point)
- [`center_point`](#function-center_point)
- [`set_center_point`](#function-set_center_point)
- [`offset`](#function-offset)
- [`set_offset`](#function-set_offset)
- [`rotation_angle`](#function-rotation_angle)
- [`set_rotation_angle`](#function-set_rotation_angle)
- [`rotation_angle_in_degrees`](#function-rotation_angle_in_degrees)
- [`set_rotation_angle_in_degrees`](#function-set_rotation_angle_in_degrees)
- [`scale`](#function-scale)
- [`set_scale`](#function-set_scale)
- [`transform_matrix`](#function-transform_matrix)
- [`set_transform_matrix`](#function-set_transform_matrix)
- [`snap_to_pixels`](#function-snap_to_pixels)
- [`set_snap_to_pixels`](#function-set_snap_to_pixels)

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

### from_brush

```rust
fn from_brush(brush: &Rc<CompositionBrush>) -> Option<CompositionSurfaceBrush>
```

The handle of `brush` as a surface brush, if it is one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L973)

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

### surface

```rust
fn surface(self: &Self) -> Option<Rc<dyn ICompositionSurface>>
```

The surface the brush paints.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L994)

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

### set_surface

```rust
fn set_surface(self: &Self, value: Option<Rc<dyn ICompositionSurface>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L998)

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

### stretch

```rust
fn stretch(self: &Self) -> CompositionStretch
```

How the surface is sized in the area of the brush (default `Fill`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1004)

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

### set_stretch

```rust
fn set_stretch(self: &Self, value: CompositionStretch)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1008)

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

### horizontal_alignment_ratio

```rust
fn horizontal_alignment_ratio(self: &Self) -> f32
```

Where the surface is placed horizontally: 0 left, 0.5 centred
(default), 1 right.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1014)

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

### set_horizontal_alignment_ratio

```rust
fn set_horizontal_alignment_ratio(self: &Self, value: f32)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1018)

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

### vertical_alignment_ratio

```rust
fn vertical_alignment_ratio(self: &Self) -> f32
```

Where the surface is placed vertically: 0 top, 0.5 centred (default),
1 bottom.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1024)

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

### set_vertical_alignment_ratio

```rust
fn set_vertical_alignment_ratio(self: &Self, value: f32)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1028)

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

### bitmap_interpolation_mode

```rust
fn bitmap_interpolation_mode(self: &Self) -> CompositionBitmapInterpolationMode
```

How a bitmap surface is resampled (default `Linear`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1033)

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

### set_bitmap_interpolation_mode

```rust
fn set_bitmap_interpolation_mode(self: &Self, value: CompositionBitmapInterpolationMode)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1037)

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

### anchor_point

```rust
fn anchor_point(self: &Self) -> Vector
```

The point of the content, relative to the area of the brush, placed
at `offset`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1043)

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

### set_anchor_point

```rust
fn set_anchor_point(self: &Self, value: Vector)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1047)

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

### center_point

```rust
fn center_point(self: &Self) -> Vector
```

The point the content is scaled and rotated about.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1052)

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

### set_center_point

```rust
fn set_center_point(self: &Self, value: Vector)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1056)

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

### offset

```rust
fn offset(self: &Self) -> Vector
```

The offset of the content.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1061)

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

### set_offset

```rust
fn set_offset(self: &Self, value: Vector)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1065)

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

### rotation_angle

```rust
fn rotation_angle(self: &Self) -> f32
```

The rotation of the content about its center point, in radians.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1070)

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

### set_rotation_angle

```rust
fn set_rotation_angle(self: &Self, value: f32)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1074)

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

### rotation_angle_in_degrees

```rust
fn rotation_angle_in_degrees(self: &Self) -> f32
```

The rotation in degrees: a view of
`rotation_angle` (not an animation target).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1080)

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

### set_rotation_angle_in_degrees

```rust
fn set_rotation_angle_in_degrees(self: &Self, value: f32)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1084)

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

### scale

```rust
fn scale(self: &Self) -> Vector
```

The scale of the content about its center point (default `(1, 1)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1089)

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

### set_scale

```rust
fn set_scale(self: &Self, value: Vector)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1093)

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

### transform_matrix

```rust
fn transform_matrix(self: &Self) -> Matrix
```

The transform matrix of the content (WinUI `Matrix3x2`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1098)

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

### set_transform_matrix

```rust
fn set_transform_matrix(self: &Self, value: Matrix)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1102)

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

### snap_to_pixels

```rust
fn snap_to_pixels(self: &Self) -> bool
```

Whether the content is aligned to device pixels.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1107)

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

### set_snap_to_pixels

```rust
fn set_snap_to_pixels(self: &Self, value: bool)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_brush.rs#L1111)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Deref`

## Availability

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