shiftOntoScreen method

void shiftOntoScreen({
  1. double? buffer,
})

Implementation

void shiftOntoScreen({double? buffer}) {
  var spaceLengths = [FRAME_X_RADIUS, FRAME_Y_RADIUS];

  buffer ??= DEFAULT_MOBJECT_TO_EDGE_BUFFER;

  for (var vec in [UP, DOWN, LEFT, RIGHT]) {
    var dim = argmax(vec.abs().toList());
    var maxVal = spaceLengths[dim];
    var edgeCenter = getEdgeCenter(vec);
    if (edgeCenter.dot(vec) > maxVal) {
      toEdge(edge: vec, buffer: buffer);
    }
  }
}