matrix property

Matrix4 get matrix

Implementation

Matrix4 get matrix {
  if (_matrixCached) {
    return _matrix;
  }

  _matrix
    ..setIdentity()
    ..translate(_position.x, _position.y);

  if (_angle != 0) {
    _matrix.rotateZ(_angle);
  }

  if (_scale.x != 1 || _scale.y != 1) {
    _matrix.scale(_scale.x, _scale.y);
  }

  if (_skew.x != 0 || _skew.y != 0) {
    _matrix.multiply(Matrix4.skew(_skew.x, _skew.y));
  }

  if (_offset.x != 0 || _offset.y != 0) {
    _matrix.translate(_offset.x, _offset.y);
  }

  _matrixCached = true;
  return _matrix;
}