DiscreteRotation


value class DiscreteRotation


Kotlin value class that represents fixed 0, 90, 180, 270 degree rotations with utility functions for adding and subtracting discrete rotations from each other.

A DiscreteRotation represents integer degrees in fixed 90 degree increments.

Summary

Public companion functions

DiscreteRotation
from(degrees: Int)

Convert integer degrees to a DiscreteRotation

DiscreteRotation
fromSurfaceRotation(surfaceRotation: Int)

Get a DiscreteRotation from Surface rotation values.

DiscreteRotation
round(degrees: Float)

Round degrees to the nearest DiscreteRotation (0, 90, 180, 270).

DiscreteRotation
round(degrees: Int)

Round degrees to the nearest DiscreteRotation (0, 90, 180, 270).

Public functions

inline operator DiscreteRotation
minus(degrees: Int)

Subtract degrees from this, modding the result by 360.

inline operator DiscreteRotation

Subtract a DiscreteRotation from this, modding the result by 360.

inline operator DiscreteRotation
plus(degrees: Int)

Add degrees to this, modding the result by 360.

inline operator DiscreteRotation

Add a DiscreteRotation from this, modding the result by 360.

open String

Public properties

Int

Public companion functions

from

Added in 1.7.0-alpha02
fun from(degrees: Int): DiscreteRotation

Convert integer degrees to a DiscreteRotation

fromSurfaceRotation

Added in 1.7.0-alpha02
fun fromSurfaceRotation(surfaceRotation: Int): DiscreteRotation

Get a DiscreteRotation from Surface rotation values.

Rotation values are relative to the device's "natural" rotation, Surface.ROTATION_0.

round

Added in 1.7.0-alpha02
fun round(degrees: Float): DiscreteRotation

Round degrees to the nearest DiscreteRotation (0, 90, 180, 270).

Negative values are rounded to the nearest positive DiscreteRotation (e.g. -90 rounds to 270). Boundary values (e.g. 45.0) are rounded up to the nearest 90-degree increment (e.g. 45.0 rounds to 90).

See also
round

round

Added in 1.7.0-alpha02
fun round(degrees: Int): DiscreteRotation

Round degrees to the nearest DiscreteRotation (0, 90, 180, 270).

Negative values are rounded to the nearest positive DiscreteRotation (e.g. -90 rounds to 270). Boundary values (e.g. 45) are rounded up to the nearest 90-degree increment (e.g. 45 rounds to 90).

See also
round

Public companion properties

ROTATION_0

val ROTATION_0DiscreteRotation

ROTATION_180

val ROTATION_180DiscreteRotation

ROTATION_270

val ROTATION_270DiscreteRotation

ROTATION_90

val ROTATION_90DiscreteRotation

Public functions

minus

Added in 1.7.0-alpha02
inline operator fun minus(degrees: Int): DiscreteRotation

Subtract degrees from this, modding the result by 360.

minus

Added in 1.7.0-alpha02
inline operator fun minus(other: DiscreteRotation): DiscreteRotation

Subtract a DiscreteRotation from this, modding the result by 360.

plus

Added in 1.7.0-alpha02
inline operator fun plus(degrees: Int): DiscreteRotation

Add degrees to this, modding the result by 360.

plus

Added in 1.7.0-alpha02
inline operator fun plus(other: DiscreteRotation): DiscreteRotation

Add a DiscreteRotation from this, modding the result by 360.

toString

open fun toString(): String

Public properties

degrees

Added in 1.7.0-alpha02
val degreesInt