replace method

void replace(
  1. Mobject mob, {
  2. int dimToMatch = 0,
  3. bool stretch = false,
})

Implementation

void replace(Mobject mob, {int dimToMatch = 0, bool stretch = false}) {
  if (hasNoPoints() && submobjects.isEmpty) {
    throw 'Attempting to replace a mobject with no points';
  }

  if (stretch) {
    stretchToFitWidth(mob.getWidth());
    stretchToFitHeight(mob.getHeight());
  } else {
    rescaleToFit(
      mob.lengthOverDim(dimToMatch),
      dimToMatch,
      stretch: false,
    );
  }

  shift(mob.getCenter() - getCenter());
}