# Spring

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

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

```rust
struct Spring
```

Determines how an animation is used based on spring formula.

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

## Members

- [`new`](#function-new)
- [`with_values`](#function-with_values)
- [`parse`](#function-parse)
- [`mass`](#function-mass)
- [`set_mass`](#function-set_mass)
- [`stiffness`](#function-stiffness)
- [`set_stiffness`](#function-set_stiffness)
- [`damping`](#function-damping)
- [`set_damping`](#function-set_damping)
- [`initial_velocity`](#function-initial_velocity)
- [`set_initial_velocity`](#function-set_initial_velocity)
- [`get_spring_progress`](#function-get_spring_progress)

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

### new

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

Creates a spring with all parameters zero.

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

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

### with_values

```rust
fn with_values(mass: f64, stiffness: f64, damping: f64, initial_velocity: f64) -> Self
```

Creates a spring with the given parameters.

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

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

### parse

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

Parses a spring from four numbers: mass, stiffness, damping and
initial velocity.

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

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

### mass

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

The spring mass.

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

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

### set_mass

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



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

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

### stiffness

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

The spring stiffness.

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

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

### set_stiffness

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



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

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

### damping

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

The spring damping.

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

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

### set_damping

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



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

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

### initial_velocity

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

The spring initial velocity.

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

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

### set_initial_velocity

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



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

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

### get_spring_progress

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

Calculates the spring progress from a linear progress.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`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`
- `PartialEq`
- `Default`
- `FromStr`

## Availability

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