An immutable 2D floating-point offset.

An Offset represents a vector from an unspecified Point.

Adding an offset to a Point returns the Point that is indicated by the vector from that first point.

Inheritance

Constants

infinite Offset

An offset with infinite x and y components.

const Offset(double.INFINITY, double.INFINITY)
zero Offset

An offset with zero magnitude.

const Offset(0.0, 0.0)

Static Methods

lerp(Offset a, Offset b, double t) Offset

Linearly interpolate between two offsets.

Constructors

Offset(double dx, double dy)

Creates an offset. The first argument sets dx, the horizontal component, and the second sets dy, the vertical component.

const

Properties

distance double

The magnitude of the offset.

read-only
distanceSquared double

The square of the magnitude of the offset.

read-only
dx double

The x component of the offset.

read-only
dy double

The y component of the offset.

read-only
hashCode int

read-only, inherited
isInfinite bool

Returns true if either dimension is double.INFINITY, and false if both are finite (or negative infinity, or NaN).

read-only, inherited
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator %(double operand) Offset

Modulo (remainder) operator. Returns an offset whose coordinates are the remainder of dividing the coordinates of the left-hand-side operand (an Offset) by the scalar right-hand-side operand (a double).

operator &(Size other) Rect

Rectangle constructor operator. Combines an offset and a Size to form a Rect whose top-left coordinate is the point given by adding this offset, the left-hand-side operand, to the origin, and whose size is the right-hand-side operand.

operator *(double operand) Offset

Multiplication operator. Returns an offset whose coordinates are the coordinates of the left-hand-side operand (an Offset) multiplied by the scalar right-hand-side operand (a double).

operator +(Offset other) 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.

operator -(Offset other) Offset

Binary subtraction operator. Returns an offset whose dx value is the left-hand-side operand's dx minus the right-hand-side operand's dx and whose dy value is the left-hand-side operand's dy minus the right-hand-side operand's dy.

operator /(double operand) Offset

Division operator. Returns an offset whose coordinates are the coordinates of the left-hand-side operand (an Offset) divided by the scalar right-hand-side operand (a double).

operator ==(other) bool

Compares two Offsets for equality.

operator unary-() Offset

Unary negation operator. Returns an offset with the coordinates negated.

operator ~/(double operand) Offset

Integer (truncating) division operator. Returns an offset whose coordinates are the coordinates of the left-hand-side operand (an Offset) divided by the scalar right-hand-side operand (a double), rounded towards zero.

operator <(OffsetBase other) bool

Less-than operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are smaller than the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

inherited
operator <=(OffsetBase other) bool

Less-than-or-equal-to operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are smaller than or equal to the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

inherited
operator >(OffsetBase other) bool

Greater-than operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are bigger than the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

inherited
operator >=(OffsetBase other) bool

Greater-than-or-equal-to operator. Compares an Offset or Size to another Offset or Size, and returns true if both the horizontal and vertical values of the left-hand-side operand are bigger than or equal to the horizontal and vertical values of the right-hand-side operand respectively. Returns false otherwise.

inherited

Methods

scale(double scaleX, double scaleY) Offset

Returns a new offset with the x component scaled by scaleX and the y component scaled by scaleY.

toPoint() Point

Returns the point at (0, 0) plus this offset.

toString() String

Returns a string representation of this object.

translate(double translateX, double translateY) Offset

Returns a new offset with translateX added to the x component and translateY added to the y component.

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited