scaleDimension method

void scaleDimension(
  1. Axis axis,
  2. double s
)

Scale so that specified dimension matches specified value.

Implementation

void scaleDimension(Axis axis, double s)
{
  double currentAspectRatio = aspectRatio();
  switch (axis)
  {
    case Axis.X:
      width = s;
      height = (1 / currentAspectRatio) * s;
      break;
    case Axis.Y:
      height = s;
      width = currentAspectRatio * s;
      break;
    default:
      throw new IllegalArgumentException("Bad axis argument.");
  }
}