Offset
data class Offset : OffsetBase
kotlin.Any  
↳  androidx.ui.engine.geometry.Offset 
An immutable 2D floatingpoint offset.
Generally speaking, Offsets can be interpreted in two ways:
 As representing a point in Cartesian space a specified distance from a separatelymaintained origin. For example, the topleft position of children in the RenderBox protocol is typically represented as an Offset from the top left of the parent box.
 As a vector that can be applied to coordinates. For example, when painting a RenderObject, the parent is passed an Offset from the screen's origin which it can add to the offsets of its children to find the Offset from the screen's origin to each of the children.
Because a particular Offset can be interpreted as one sense at one time then as the other sense at a later time, the same class is used for both senses.
See also:
 Size, which represents a vector describing the size of a rectangle.
Creates an offset. The first argument sets dx, the horizontal component, and the second sets dy, the vertical component.
Summary
Public constructors 


An immutable 2D floatingpoint offset. 
Public methods 


infix Rect 
Rectangle constructor operator. 
operator Offset 
Division operator. 
Boolean  
Float 
The angle of this offset as radians clockwise from the positive xaxis, in the range pi to pi, assuming positive values of the xaxis go to the left and positive values of the yaxis go down. 
Float 
The magnitude of the offset. 
Float 
The square of the magnitude of the offset. 
Int 
hashCode() 
operator Offset 
Binary subtraction operator. 
operator Offset 
Binary addition operator. 
operator Offset 
Modulo (remainder) operator. 
Offset 
Returns a new offset with the x component scaled by 
operator Offset 
Multiplication operator. 
String 
toString() 
Offset 
Returns a new offset with translateX added to the x component and translateY added to the y component. 
Offset 
Integer (truncating) division operator. 
operator Offset 
Unary negation operator. 
Companion functions 


Boolean  
Offset 
Linearly interpolate between two offsets. 
Inherited functions 


Extension functions 


From androidx.ui.engine.geometry

Properties 


Float  
Float 
Companion properties 


Offset 
An offset with infinite x and y components. 
Offset 
An offset with zero magnitude. 
Public constructors
<init>
Offset(
dx: Float,
dy: Float)
An immutable 2D floatingpoint offset.
Generally speaking, Offsets can be interpreted in two ways:
 As representing a point in Cartesian space a specified distance from a separatelymaintained origin. For example, the topleft position of children in the RenderBox protocol is typically represented as an Offset from the top left of the parent box.
 As a vector that can be applied to coordinates. For example, when painting a RenderObject, the parent is passed an Offset from the screen's origin which it can add to the offsets of its children to find the Offset from the screen's origin to each of the children.
Because a particular Offset can be interpreted as one sense at one time then as the other sense at a later time, the same class is used for both senses.
See also:
 Size, which represents a vector describing the size of a rectangle.
Creates an offset. The first argument sets dx, the horizontal component, and the second sets dy, the vertical component.
Public methods
and
infix fun and(other: Size): Rect
Rectangle constructor operator.
Combines an Offset and a Size to form a Rect whose topleft coordinate is the point given by adding this offset, the lefthandside operand, to the origin, and whose size is the righthandside operand.
Rect myRect = Offset.zero & const Size(100.0, 100.0); // same as: new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)
div
operator fun div(operand: Float): Offset
Division operator.
Returns an offset whose coordinates are the coordinates of the lefthandside operand (an Offset) divided by the scalar righthandside operand (a Float).
See also scale.
getDirection
fun getDirection(): Float
The angle of this offset as radians clockwise from the positive xaxis, in the range pi to pi, assuming positive values of the xaxis go to the left and positive values of the yaxis go down.
Zero means that dy is zero and dx is zero or positive.
Values from zero to pi/2 indicate positive values of dx and dy, the bottomright quadrant.
Values from pi/2 to pi indicate negative values of dx and positive values of dy, the bottomleft quadrant.
Values from zero to pi/2 indicate positive values of dx and negative values of dy, the topright quadrant.
Values from pi/2 to pi indicate negative values of dx and dy, the topleft quadrant.
When dy is zero and dx is negative, the direction is pi.
When dx is zero, direction is pi/2 if dy is positive and pi/2 if dy is negative.
See also:
 distance, to compute the magnitude of the vector.
 Canvas.rotate, which uses the same convention for its angle.
getDistance
fun getDistance(): Float
The magnitude of the offset.
If you need this value to compare it to another Offset's distance, consider using getDistanceSquared instead, since it is cheaper to compute.
getDistanceSquared
fun getDistanceSquared(): Float
The square of the magnitude of the offset.
This is cheaper than computing the getDistance itself.
hashCode
fun hashCode(): Int
minus
operator fun minus(other: Offset): Offset
Binary subtraction operator.
Returns an offset whose dx value is the lefthandside operand's dx minus the righthandside operand's dx and whose dy value is the lefthandside operand's dy minus the righthandside operand's dy.
See also translate.
plus
operator fun plus(other: Offset): Offset
Binary addition operator.
Returns an offset whose dx value is the sum of the dx values of the two operands, and whose dy value is the sum of the dy values of the two operands.
See also translate.
rem
operator fun rem(operand: Float): Offset
Modulo (remainder) operator.
Returns an offset whose coordinates are the remainder of dividing the coordinates of the lefthandside operand (an Offset) by the scalar righthandside operand (a Float).
scale
fun scale(
scaleX: Float,
scaleY: Float
): Offset
Returns a new offset with the x component scaled by scaleX
and the y
component scaled by scaleY
.
If the two scale arguments are the same, consider using the *
operator
instead:
Offset a = const Offset(10.0, 10.0); Offset b = a * 2.0; // same as: a.scale(2.0, 2.0)
If the two arguments are 1, consider using the unary 
operator
instead:
Offset a = const Offset(10.0, 10.0); Offset b = a; // same as: a.scale(1.0, 1.0)
times
operator fun times(operand: Float): Offset
Multiplication operator.
Returns an offset whose coordinates are the coordinates of the lefthandside operand (an Offset) multiplied by the scalar righthandside operand (a Float).
See also scale.
toString
fun toString(): String
translate
fun translate(
translateX: Float,
translateY: Float
): Offset
Returns a new offset with translateX added to the x component and translateY added to the y component.
If the arguments come from another Offset, consider using the +
or 
operators instead:
Offset a = const Offset(10.0, 10.0); Offset b = const Offset(10.0, 10.0); Offset c = a + b; // same as: a.translate(b.dx, b.dy) Offset d = a  b; // same as: a.translate(b.dx, b.dy)
truncDiv
fun truncDiv(operand: Float): Offset
Integer (truncating) division operator.
Returns an offset whose coordinates are the coordinates of the lefthandside operand (an Offset) divided by the scalar righthandside operand (a Float), rounded towards zero.
unaryMinus
operator fun unaryMinus(): Offset
Unary negation operator.
Returns an offset with the coordinates negated.
If the Offset represents an arrow on a plane, this operator returns the same arrow but pointing in the reverse direction.
Properties
dx
val dx: Float
dy
val dy: Float
Companion functions
lerp
fun lerp(
start: Offset,
stop: Offset,
fraction: Float
): Offset
Linearly interpolate between two offsets.
The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).
Values for fraction are usually obtained from an Animation, such as
an AnimationController
.
Companion properties
infinite
val infinite: Offset
An offset with infinite x and y components.
See also:
 isInfinite, which checks whether either component is infinite.
 isFinite, which checks whether both components are finite.
zero
val zero: Offset
An offset with zero magnitude.
This can be used to represent the origin of a coordinate space.