docs: def calculate_offset(percent, original_length, length):
          """
          Calculates crop offset based on percentage.
  
          :param percent: A percentage representing the size of the offset.
          :param original_length: The length the distance that should be cropped.
          :param length: The desired length.
          :return: The offset in pixels
          :rtype: int
          """
          return int(
              max(
                  0,
                  min(percent * original_length / 100.0, original_length - length / 2) - length / 2)
          )