# Pen

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

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

```rust
struct Pen
```

Describes how a stroke is drawn.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`brush_property`](#function-brush_property)
- [`thickness_property`](#function-thickness_property)
- [`dash_style_property`](#function-dash_style_property)
- [`line_cap_property`](#function-line_cap_property)
- [`line_join_property`](#function-line_join_property)
- [`miter_limit_property`](#function-miter_limit_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`with_brush`](#function-with_brush)
- [`from_uint32`](#function-from_uint32)
- [`with_all`](#function-with_all)
- [`brush`](#function-brush)
- [`set_brush`](#function-set_brush)
- [`thickness`](#function-thickness)
- [`set_thickness`](#function-set_thickness)
- [`dash_style`](#function-dash_style)
- [`set_dash_style`](#function-set_dash_style)
- [`line_cap`](#function-line_cap)
- [`set_line_cap`](#function-set_line_cap)
- [`line_join`](#function-line_join)
- [`set_line_join`](#function-set_line_join)
- [`miter_limit`](#function-miter_limit)
- [`set_miter_limit`](#function-set_miter_limit)
- [`to_immutable`](#function-to_immutable)
- [`try_modify_or_create`](#function-try_modify_or_create)
- [`invalidated`](#function-invalidated)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

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

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<Pen>
```

Returns a strong reference to this object.

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

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

### brush_property

```rust
fn brush_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
```



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

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

### thickness_property

```rust
fn thickness_property() -> &'static StyledProperty<f64>
```



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

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

### dash_style_property

```rust
fn dash_style_property() -> &'static StyledProperty<Option<Rc<dyn IDashStyle>>>
```



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

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

### line_cap_property

```rust
fn line_cap_property() -> &'static StyledProperty<PenLineCap>
```



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

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

### line_join_property

```rust
fn line_join_property() -> &'static StyledProperty<PenLineJoin>
```



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

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

### miter_limit_property

```rust
fn miter_limit_property() -> &'static StyledProperty<f64>
```



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

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

### construct

```rust
fn construct() -> Self
```

Creates the class data.

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

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

### new

```rust
fn new() -> Ref<Self>
```

Creates a pen with default values.

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

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

### with_brush

```rust
fn with_brush(brush: Option<Rc<dyn IBrush>>, thickness: f64) -> Ref<Self>
```

Creates a solid pen with the given brush and thickness: no dashes,
flat caps, miter joins and a miter limit of 10.

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

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

### from_uint32

```rust
fn from_uint32(color: u32, thickness: f64) -> Ref<Self>
```

Creates a solid pen with the color given as an `0xAARRGGBB` value.

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

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

### with_all

```rust
fn with_all(brush: Option<Rc<dyn IBrush>>, thickness: f64, dash_style: Option<Rc<dyn IDashStyle>>, line_cap: PenLineCap, line_join: PenLineJoin, miter_limit: f64) -> Ref<Self>
```

Creates a pen.

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

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

### brush

```rust
fn brush(self: &Self) -> Option<Rc<dyn IBrush>>
```

The brush used to draw the stroke.

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

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

### set_brush

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



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

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

### thickness

```rust
fn thickness(self: &Self) -> f64
```

The stroke thickness.

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

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

### set_thickness

```rust
fn set_thickness(self: &Self, value: f64)
```



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

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

### dash_style

```rust
fn dash_style(self: &Self) -> Option<Rc<dyn IDashStyle>>
```

The style of dashed lines drawn with the pen.

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

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

### set_dash_style

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



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

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

### line_cap

```rust
fn line_cap(self: &Self) -> PenLineCap
```

The type of shape to use on both ends of a line.

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

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

### set_line_cap

```rust
fn set_line_cap(self: &Self, value: PenLineCap)
```



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

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

### line_join

```rust
fn line_join(self: &Self) -> PenLineJoin
```

A value describing how to join consecutive line or curve segments.

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

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

### set_line_join

```rust
fn set_line_join(self: &Self, value: PenLineJoin)
```



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

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

### miter_limit

```rust
fn miter_limit(self: &Self) -> f64
```

The limit of the ratio of the miter length to half this pen's
thickness.

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

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

### set_miter_limit

```rust
fn set_miter_limit(self: &Self, value: f64)
```



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

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

### to_immutable

```rust
fn to_immutable(self: &Self) -> ImmutablePen
```

Creates an immutable clone of the pen.

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

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

### try_modify_or_create

```rust
fn try_modify_or_create(pen: &mut Option<Rc<dyn IPen>>, brush: Option<Rc<dyn IBrush>>, thickness: f64, stroke_dash_array: Option<StrokeDashArray<'_>>, stroke_dash_offset: f64, line_cap: PenLineCap, line_join: PenLineJoin, miter_limit: f64) -> bool
```

Smart reuse and update of a pen.

If `brush` is `None`, `pen` is cleared. If the brush and the dashes
are immutable, a new immutable pen is created. Otherwise the existing
mutable pen is updated, or a new mutable pen is created.

Returns true if `pen` was created or cleared, false if the existing
pen was modified in place.

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

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

### invalidated

```rust
fn invalidated(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
```

Subscribes to invalidation of the pen: raised whenever a change
requires strokes drawn with the pen to be redrawn. Dropping the
returned guard removes the handler; `Subscription::detach` keeps it
for the life of the pen.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Pen>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- `ICompositionRenderResource`
- [`IAffectsRender`](/docs/0.5.0/api/ferroui-base/media/trait-iaffectsrender/)

## Availability

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