public final function reduceToMaxSize( Size $maxSize ) : bool
   {

      $this->triggerFixedErrorByNeed( 'reduceToMaxSize' );

      if ( ( $this->_width  < $maxSize->_width )
        && ( $this->_height < $maxSize->_height ) )
      {
         return false;
      }

      if ( ( $this->_width  === $maxSize->_width )
        && ( $this->_height === $maxSize->_height ) )
      {
         return true;
      }

      $dw = $this->_width / $maxSize->_width;
      $dh = $this->_height / $maxSize->_height;

      if ( $dw < $dh )
      {
         $this->_width = \intval(
            \floor(
               ( $this->_width * $maxSize->_height ) / $this->_height
            )
         );
         $this->_height = $maxSize->_height;
      }
      else if ( $dw > $dh )
      {
         $this->_height = \intval(
            \floor(
               ( $maxSize->_width * $this->_height ) / $this->_width
            )
         );
         $this->_width = $maxSize->_width;
      }
      else # ($dw == $dh)
      {
         $this->_width  = $maxSize->_width;
         $this->_height = $maxSize->_height;
      }

      return true;

   }
public final function reduceToMaxSize( Size $maxSize ) : bool
   {

      $this->triggerFixedErrorByNeed( 'reduceToMaxSize' );

      if ( ( $this->_width  < $maxSize->_width )
        && ( $this->_height < $maxSize->_height ) )
      {
         return false;
      }

      if ( ( $this->_width  === $maxSize->_width )
        && ( $this->_height === $maxSize->_height ) )
      {
         return true;
      }

      $dw = $this->_width / $maxSize->_width;
      $dh = $this->_height / $maxSize->_height;

      if ( $dw < $dh )
      {
         $this->_width = \intval(
            \floor(
               ( $this->_width * $maxSize->_height ) / $this->_height
            )
         );
         $this->_height = $maxSize->_height;
      }
      else if ( $dw > $dh )
      {
         $this->_height = \intval(
            \floor(
               ( $maxSize->_width * $this->_height ) / $this->_width
            )
         );
         $this->_width = $maxSize->_width;
      }
      else # ($dw == $dh)
      {
         $this->_width  = $maxSize->_width;
         $this->_height = $maxSize->_height;
      }

      return true;

   }
public final function reduceToMaxSize ( Size $ maxSize ) : bool { $ this -> triggerFixedErrorByNeed ( 'reduceToMaxSize' ) ; if ( ( $ this -> _width < $ maxSize -> _width ) && ( $ this -> _height < $ maxSize -> _height ) ) { return false ; } if ( ( $ this -> _width === $ maxSize -> _width ) && ( $ this -> _height === $ maxSize -> _height ) ) { return true ; } $ dw = $ this -> _width / $ maxSize -> _width ; $ dh = $ this -> _height / $ maxSize -> _height ; if ( $ dw < $ dh ) { $ this -> _width = \ intval ( \ floor ( ( $ this -> _width * $ maxSize -> _height ) / $ this -> _height ) ) ; $ this -> _height = $ maxSize -> _height ; } else if ( $ dw > $ dh ) { $ this -> _height = \ intval ( \ floor ( ( $ maxSize -> _width * $ this -> _height ) / $ this -> _width ) ) ; $ this -> _width = $ maxSize -> _width ; } else # ($dw == $dh) { $ this -> _width = $ maxSize -> _width ; $ this -> _height = $ maxSize -> _height ; } return true ; }
Decrease the current size to fit the defined Size, by holding its proportions.

@param  \Beluga\Drawing\Size $maxSize
@return bool TRUE on success, or FALSE, if current size is already smaller than defined size.
@throws \Beluga\BelugaError  If the instance is set to fixed.
Decrease the current size to fit the defined Size by holding its proportions .