mapZoomFit property

set mapZoomFit (InitialMapZoomFitEnum value)

Implementation

set mapZoomFit(InitialMapZoomFitEnum value) {
  config.initialMapZoomFit = value;
  Vector2 sizeScreen = canvasSize;
  switch (value) {
    case InitialMapZoomFitEnum.none:
      break;
    case InitialMapZoomFitEnum.fitWidth:
      zoom = sizeScreen.x / gameRef.map.getMapSize().x;
      break;
    case InitialMapZoomFitEnum.fitHeight:
      zoom = sizeScreen.y / gameRef.map.getMapSize().y;
      break;
    case InitialMapZoomFitEnum.fit:
      double minScreenDimension = min(sizeScreen.x, sizeScreen.y);
      double minMapDimension = max(
        gameRef.map.getMapSize().x,
        gameRef.map.getMapSize().y,
      );
      zoom = minScreenDimension / minMapDimension;
      break;
  }
}