# KeySpline

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/animation/struct-keyspline/

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

```rust
struct KeySpline
```

Determines how an animation is used based on a cubic bezier curve. X1
and X2 must be between 0.0 and 1.0, inclusive.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L16)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`with_points`](#function-with_points)
- [`parse`](#function-parse)
- [`control_point_x1`](#function-control_point_x1)
- [`set_control_point_x1`](#function-set_control_point_x1)
- [`control_point_y1`](#function-control_point_y1)
- [`set_control_point_y1`](#function-set_control_point_y1)
- [`control_point_x2`](#function-control_point_x2)
- [`set_control_point_x2`](#function-set_control_point_x2)
- [`control_point_y2`](#function-control_point_y2)
- [`set_control_point_y2`](#function-set_control_point_y2)
- [`get_spline_progress`](#function-get_spline_progress)
- [`is_valid`](#function-is_valid)

<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/animation/key_spline.rs#L40)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L40)

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

### construct

```rust
fn construct(x1: f64, y1: f64, x2: f64, y2: f64) -> Self
```

Creates the class data; see `FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L46)

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

### new

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

Creates a key spline with the default control points `(0, 0)` and
`(1, 1)`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L67)

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

### with_points

```rust
fn with_points(x1: f64, y1: f64, x2: f64, y2: f64) -> Ref<Self>
```

Creates a key spline with the given control points. The points are
not validated here; see `is_valid`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L73)

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

### parse

```rust
fn parse(value: &str) -> Result<Ref<KeySpline>, FormatError>
```

Parses a key spline from four numbers.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L78)

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

### control_point_x1

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

X coordinate of the first control point.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L90)

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

### set_control_point_x1

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

Sets the X coordinate of the first control point. Panics when the
value is outside `[0, 1]`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L96)

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

### control_point_y1

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

Y coordinate of the first control point.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L106)

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

### set_control_point_y1

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L110)

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

### control_point_x2

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

X coordinate of the second control point.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L116)

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

### set_control_point_x2

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

Sets the X coordinate of the second control point. Panics when the
value is outside `[0, 1]`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L122)

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

### control_point_y2

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

Y coordinate of the second control point.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L132)

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

### set_control_point_y2

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L136)

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

### get_spline_progress

```rust
fn get_spline_progress(self: &Self, linear_progress: f64) -> f64
```

Calculates the spline progress from a linear progress.

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

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

### is_valid

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

Checks whether the spline control points are valid: both X values
within `[0, 1]`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/key_spline.rs#L158)

## 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<KeySpline>`](/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/)

## Availability

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