# FloatTweenSpec

Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/FloatAnimationSpec.kt+class:androidx.compose.animation.core.FloatTweenSpec) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0) Common/All
- Cmn

  ```
  class FloatTweenSpec : FloatAnimationSpec
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec` animates a Float value from any start value to any end value using a provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)` function. The animation will finish within the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)` time. Unless a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)` is specified, the animation will start right away.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#FloatTweenSpec(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)(duration: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, delay: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, easing: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Easing)` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#getDurationNanos(kotlin.Float,kotlin.Float,kotlin.Float)( initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Calculates the duration of an animation. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#getValueFromNanos(kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float)( playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#getVelocityFromNanos(kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float)( playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#delay()` the amount of time the animation will wait before it starts running. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#duration()` the amount of time (in milliseconds) the animation will take to finish. | Cmn |

| ### Inherited functions |
|---|
| From [androidx.compose.animation.core.FloatAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec) |---|---|---| | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec#getEndVelocity(kotlin.Float,kotlin.Float,kotlin.Float)( initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Calculates the end velocity of the animation with the provided start/end values, and start velocity. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFloatAnimationSpec<V>` | `<V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec#vectorize(androidx.compose.animation.core.TwoWayConverter)(converter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, V>)` Create an `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` that animates `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` from a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec`. | Cmn | |

## Public constructors

### FloatTweenSpec

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
FloatTweenSpec(
    duration: Int = DefaultDurationMillis,
    delay: Int = 0,
    easing: Easing = FastOutSlowInEasing
)
```

| Parameters |
|---|---|
| `duration: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = DefaultDurationMillis` | the amount of time (in milliseconds) the animation will take to finish. Defaults to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#DefaultDurationMillis()` |
| `delay: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the amount of time the animation will wait before it starts running. Defaults to 0. |
| `easing: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Easing = FastOutSlowInEasing` | the easing function that will be used to interoplate between the start and end value of the animation. Defaults to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#FastOutSlowInEasing()`. |

## Public functions

### getDurationNanos

Cmn

```
open fun getDurationNanos(
    initialValue: Float,
    targetValue: Float,
    initialVelocity: Float
): Long
```

Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec#getDurationNanos(kotlin.Float,kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec#getDurationNanos(kotlin.Float,kotlin.Float,kotlin.Float)` values, and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec#getDurationNanos(kotlin.Float,kotlin.Float,kotlin.Float)`.

**Note**: this may be a computation that is expensive - especially with spring based animations

| Parameters |
|---|---|
| `initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | start value of the animation |
| `targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | end value of the animation |
| `initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | start velocity of the animation |

### getValueFromNanos

Cmn

```
open fun getValueFromNanos(
    playTimeNanos: Long,
    initialValue: Float,
    targetValue: Float,
    initialVelocity: Float
): Float
```

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | time since the start of the animation |
| `initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | start value of the animation |
| `targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | end value of the animation |
| `initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | start velocity of the animation |

### getVelocityFromNanos

Cmn

```
open fun getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: Float,
    targetValue: Float,
    initialVelocity: Float
): Float
```

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | time since the start of the animation |
| `initialValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | start value of the animation |
| `targetValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | end value of the animation |
| `initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | start velocity of the animation |

## Public properties

### delay

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val delay: Int
```

the amount of time the animation will wait before it starts running. Defaults to 0.

### duration

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val duration: Int
```

the amount of time (in milliseconds) the animation will take to finish. Defaults to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationConstants#DefaultDurationMillis()`