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 |
Convert integer |
DiscreteRotation |
fromSurfaceRotation(surfaceRotation: Int)Get a |
DiscreteRotation |
Round |
DiscreteRotation |
Round |
Public companion properties |
|
|---|---|
DiscreteRotation |
|
DiscreteRotation |
|
DiscreteRotation |
|
DiscreteRotation |
Public functions |
|
|---|---|
inline operator DiscreteRotation |
Subtract |
inline operator DiscreteRotation |
minus(other: DiscreteRotation)Subtract a |
inline operator DiscreteRotation |
Add |
inline operator DiscreteRotation |
plus(other: DiscreteRotation)Add a |
open String |
toString() |
Public companion functions
from
fun from(degrees: Int): DiscreteRotation
Convert integer degrees to a DiscreteRotation
fromSurfaceRotation
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
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
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
Public functions
minus
inline operator fun minus(degrees: Int): DiscreteRotation
Subtract degrees from this, modding the result by 360.
minus
inline operator fun minus(other: DiscreteRotation): DiscreteRotation
Subtract a DiscreteRotation from this, modding the result by 360.
plus
inline operator fun plus(degrees: Int): DiscreteRotation
Add degrees to this, modding the result by 360.
plus
inline operator fun plus(other: DiscreteRotation): DiscreteRotation
Add a DiscreteRotation from this, modding the result by 360.