rotated method

Matrix<T> rotated({
  1. int count = 1,
})

Returns a mutable view onto the matrix rotated clockwise by multiples of 90 degrees.

Implementation

Matrix<T> rotated({int count = 1}) {
  var self = this;
  if (self is RotatedMatrix<T>) {
    count += self.count;
    self = self.matrix;
  }
  count = count % 4;
  return count == 0 ? self : RotatedMatrix(self, count);
}