AffineTransform class
Implements
Constructors
new AffineTransform([num scaleX = 1, num shearY = 0, num shearX = 0, num scaleY = 1, num translateX = 0, num translateY = 0]) #
AffineTransform([num scaleX = 1, num shearY = 0, num shearX = 0, num scaleY = 1, num translateX = 0, num translateY = 0]) : _m00 = scaleX, _m11 = scaleY, _m02 = translateX, _m12 = translateY, _m01 = shearX, _m10 = shearY;
factory AffineTransform.fromRotate(num theta, num x, num y) #
factory AffineTransform.fromRotate(num theta, num x, num y) { return new AffineTransform().setToRotation(theta, x, y); }
factory AffineTransform.fromScale(sx, sy) #
factory AffineTransform.fromScale(sx, sy) { return new AffineTransform().setToScale(sx, sy); }
Methods
bool operator ==(AffineTransform other) #
The equality operator.
The default behavior for all Object
s is to return true if and
only if this
and
other are the same object.
If a subclass overrides the equality operator it should override
the hashCode
method as well to maintain consistency.
bool operator ==(AffineTransform other) { return other != null && _m00 == other._m00 && _m01 == other._m01 && _m02 == other._m02 && _m10 == other._m10 && _m11 == other._m11 && _m12 == other._m12; }
AffineTransform clone() #
AffineTransform clone(){ return new AffineTransform(_m00, _m10, _m01, _m11, _m02, _m12); }
AffineTransform concatenate(tx) #
AffineTransform concatenate(tx) { var m0 = this._m00; var m1 = this._m01; this._m00 = tx._m00 * m0 + tx._m10 * m1; this._m01 = tx._m01 * m0 + tx._m11 * m1; this._m02 += tx._m02 * m0 + tx._m12 * m1; m0 = this._m10; m1 = this._m11; this._m10 = tx._m00 * m0 + tx._m10 * m1; this._m11 = tx._m01 * m0 + tx._m11 * m1; this._m12 += tx._m02 * m0 + tx._m12 * m1; return this; }
AffineTransform createInverse() #
AffineTransform createInverse() { num det = determinant; return new AffineTransform( _m11 / det, -_m10 / det, -_m01 / det, _m00 / det, (_m01 * _m12 - _m11 * _m02) / det, (_m10 * _m02 - _m00 * _m12) / det); }
num get determinant() #
num get determinant => _m00 * _m11 - _m01 * _m10;
int hashCode() #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==
. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode
it should override the
equality operator as well to maintain consistency.
external int hashCode();
bool get isIdentity() #
bool get isIdentity { return _m00 == 1 && _m10 == 0 && _m01 == 0 && _m11 == 1 && _m02 == 0 && _m12 == 0; }
noSuchMethod(String name, List args) #
noSuchMethod
is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to noSuchMethod
. If noSuchMethod
returns a value, that value becomes the result of the original
invocation.
The default behavior of noSuchMethod
is to throw a
noSuchMethodError
.
external Dynamic noSuchMethod(String name, List args);
AffineTransform rotate(num theta, num x, num y) #
AffineTransform rotate(num theta, num x, num y) { return this.concatenate(new AffineTransform.fromRotate(theta, x, y)); }
Type get runtimeType() #
A representation of the runtime type of the object.
external Type get runtimeType;
AffineTransform scale(num sx, num sy) #
AffineTransform scale(num sx, num sy) { _m00 *= sx; _m10 *= sx; _m01 *= sy; _m11 *= sy; return this; }
num get scaleX() #
num get scaleX => _m00;
num get scaleY() #
num get scaleY => _m11;
AffineTransform setFromTransfrom(AffineTransform tx) #
AffineTransform setFromTransfrom(AffineTransform tx) { requireArgumentNotNull(tx, 'tx'); return setTransform(tx._m00, tx._m10, tx._m01, tx._m11, tx._m02, tx._m12); }
AffineTransform setToRotation(num theta, num x, num y) #
AffineTransform setToRotation(num theta, num x, num y) { var cos = math.cos(theta); var sin = math.sin(theta); return this.setTransform(cos, sin, -sin, cos, x - x * cos + y * sin, y - x * sin - y * cos); }
AffineTransform setToScale(sx, sy) #
AffineTransform setToScale(sx, sy) { return setTransform(sx, 0, 0, sy, 0, 0); }
AffineTransform setToTranslation(num dx, num dy) #
AffineTransform setToTranslation(num dx, num dy) { return setTransform(1, 0, 0, 1, dx, dy); }
AffineTransform setTransform(num m00, num m10, num m01, num m11, num m02, num m12) #
AffineTransform setTransform (num m00, num m10, num m01, num m11, num m02, num m12) { this._m00 = m00; this._m10 = m10; this._m01 = m01; this._m11 = m11; this._m02 = m02; this._m12 = m12; return this; }
num get shearX() #
num get shearX => _m01;
num get shearY() #
num get shearY => _m10;
String toString() #
Returns a string representation of this object.
String toString() { final values = [translateX, translateY, scaleX, scaleY, shearX, shearY]; return Strings.join($(values).map((n) => n.toString()).toList(), ', '); }
Coordinate transformCoordinate([Coordinate point = const Coordinate()]) #
Coordinate transformCoordinate([Coordinate point = const Coordinate()]){ num x = point.x * _m00 + point.y * _m01 + _m02; num y = point.x * _m10 + point.y * _m11 + _m12; return new Coordinate(x, y); }
AffineTransform translate(num dx, num dy) #
AffineTransform translate(num dx, num dy) { _m02 += dx * _m00 + dy * _m01; _m12 += dx * _m10 + dy * _m11; return this; }
num get translateX() #
num get translateX => _m02;
num get translateY() #
num get translateY => _m12;