src/Beluga/Drawing/Image/GdImage.php
public final function negate( bool $internal = false ) : GdImage
   {

      if ( ! $internal )
      {
         $clon = clone $this;
         return $clon->negate( true );
      }

      $w = $this->getWidth();
      $h = $this->getHeight();

      $im = \imagecreatetruecolor( $w, $h );
      for ( $y = 0; $y < $h; ++$y )
      {
         for ( $x = 0; $x < $w; $x++ )
         {
            $colors = \imagecolorsforindex(
               $this->r,
               \imagecolorat( $this->r, $x, $y )
            );
            $r = 255 - $colors[ 'red' ];
            $g = 255 - $colors[ 'green' ];
            $b = 255 - $colors[ 'blue' ];
            $newColor = \imagecolorallocate( $im, $r, $g, $b );
            \imagesetpixel( $im, $x, $y, $newColor );
         }
      }
      
      \imagedestroy( $this->r );
      $this->r = null;
      
      $this->r = $im;
      
      return $this;
      
   }
public final function negate( bool $internal = false ) : GdImage
   {

      if ( ! $internal )
      {
         $clon = clone $this;
         return $clon->negate( true );
      }

      $w = $this->getWidth();
      $h = $this->getHeight();

      $im = \imagecreatetruecolor( $w, $h );
      for ( $y = 0; $y < $h; ++$y )
      {
         for ( $x = 0; $x < $w; $x++ )
         {
            $colors = \imagecolorsforindex(
               $this->r,
               \imagecolorat( $this->r, $x, $y )
            );
            $r = 255 - $colors[ 'red' ];
            $g = 255 - $colors[ 'green' ];
            $b = 255 - $colors[ 'blue' ];
            $newColor = \imagecolorallocate( $im, $r, $g, $b );
            \imagesetpixel( $im, $x, $y, $newColor );
         }
      }
      
      \imagedestroy( $this->r );
      $this->r = null;
      
      $this->r = $im;
      
      return $this;
      
   }
public final function negate ( bool $ internal = false ) : GdImage { if ( ! $ internal ) { $ clon = clone $ this ; return $ clon -> negate ( true ) ; } $ w = $ this -> getWidth ( ) ; $ h = $ this -> getHeight ( ) ; $ im = \ imagecreatetruecolor ( $ w , $ h ) ; for ( $ y = 0 ; $ y < $ h ; ++ $ y ) { for ( $ x = 0 ; $ x < $ w ; $ x ++ ) { $ colors = \ imagecolorsforindex ( $ this -> r , \ imagecolorat ( $ this -> r , $ x , $ y ) ) ; $ r = 255 - $ colors [ 'red' ] ; $ g = 255 - $ colors [ 'green' ] ; $ b = 255 - $ colors [ 'blue' ] ; $ newColor = \ imagecolorallocate ( $ im , $ r , $ g , $ b ) ; \ imagesetpixel ( $ im , $ x , $ y , $ newColor ) ; } } \ imagedestroy ( $ this -> r ) ; $ this -> r = null ; $ this -> r = $ im ; return $ this ; }
Creates a negative of current image.

@param  boolean $internal Do not create a new instance?
@return \Beluga\Drawing\Image\GdImage
Creates a negative of current image .