Android 12 Developer Preview is here! Try it out, and give us your feedback!

Velocity

@Immutable inline class Velocity
kotlin.Any
   ↳ androidx.compose.ui.unit.Velocity

A two dimensional velocity in pixels per second.

Summary

Public methods
operator Float

The horizontal component of the velocity in pixels per second.

operator Float

The vertical component of the velocity in pixels per second.

Velocity
copy(x: Float = this.x, y: Float = this.y)

Returns a copy of this Velocity instance optionally overriding the x or y parameter

operator Velocity
div(operand: Float)

Division operator.

operator Velocity
minus(other: Velocity)

Binary subtraction operator.

operator Velocity
plus(other: Velocity)

Binary addition operator.

operator Velocity
rem(operand: Float)

Modulo (remainder) operator.

operator Velocity
times(operand: Float)

Multiplication operator.

String

operator Velocity

Unary negation operator.

Properties
Float

The horizontal component of the velocity in pixels per second.

Float

The vertical component of the velocity in pixels per second.

Companion properties
Velocity

An offset with zero magnitude.

Public methods

component1

@Stable operator fun component1(): Float

The horizontal component of the velocity in pixels per second.

component2

@Stable operator fun component2(): Float

The vertical component of the velocity in pixels per second.

copy

fun copy(
    x: Float = this.x,
    y: Float = this.y
): Velocity

Returns a copy of this Velocity instance optionally overriding the x or y parameter

div

@Stable operator fun div(operand: Float): Velocity

Division operator.

Returns a Velocity whose coordinates are those of the left-hand-side operand (an Velocity) divided by the scalar right-hand-side operand (a Float).

minus

@Stable operator fun minus(other: Velocity): Velocity

Binary subtraction operator.

Returns a Velocity whose x value is the left-hand-side operand's x minus the right-hand-side operand's x and whose y value is the left-hand-side operand's y minus the right-hand-side operand's y.

plus

@Stable operator fun plus(other: Velocity): Velocity

Binary addition operator.

Returns a Velocity whose x value is the sum of the x values of the two operands, and whose y value is the sum of the y values of the two operands.

rem

@Stable operator fun rem(operand: Float): Velocity

Modulo (remainder) operator.

Returns a Velocity whose coordinates are the remainder of dividing the coordinates of the left-hand-side operand (a Velocity) by the scalar right-hand-side operand (a Float).

times

@Stable operator fun times(operand: Float): Velocity

Multiplication operator.

Returns a Velocity whose coordinates are those of the left-hand-side operand (a Velocity) multiplied by the scalar right-hand-side operand (a Float).

toString

fun toString(): String

unaryMinus

@Stable operator fun unaryMinus(): Velocity

Unary negation operator.

Returns a Velocity with the coordinates negated.

If the Velocity represents an arrow on a plane, this operator returns the same arrow but pointing in the reverse direction.

Properties

x

@Stable val x: Float

The horizontal component of the velocity in pixels per second.

y

@Stable val y: Float

The vertical component of the velocity in pixels per second.

Companion properties

Zero

@Stable val Zero: Velocity

An offset with zero magnitude.

This can be used to represent the origin of a coordinate space.