Location: PHPKode > scripts > FXLake effect > fxlake-effect/FXLake.class.php
<?php
/*
+-------------------------------------------------+
+                                                 +
+    FXLake.class.php ver. 1.0 by László Zsidi    +
+      CGI binary version on http://gifs.hu       +
+                                                 +
+    This class can be used and distributed       +
+    free of charge, but cannot be modified       +
+        without permission of author.            +
+                                                 +
+  Try on-line animated FXLake effect generator   +
+                                                 +
+     http://phpclasses.gifs.hu/demos/FXLake/     +
+                                                 +
+-------------------------------------------------+
*/

include "GIFEncoder.class.php";

define ( 'VERSION', '1.00' );
define ( ANIM_FRAMES, 12 );
define ( ANIM_DELAYS, 10 );

Class FXLake {
	/*
	:::::::::::::::::::::::::::::::::::::::::::::
	::                                         ::
	::        Class variables - integers       ::
	::                                         ::
	:::::::::::::::::::::::::::::::::::::::::::::
	*/
	var $_001;
	var $_002;
	var $_003;
	var $_004;
	var $_101;
	/*
	:::::::::::::::::::::::::::::::::::::::::::::
	::                                         ::
	::          Class variables - PID          ::
	::                                         ::
	:::::::::::::::::::::::::::::::::::::::::::::
	*/
	var $PID = 6.2831853071795862;
	/*
	:::::::::::::::::::::::::::::::::::::::::::::
	::                                         ::
	::            Class Constructor            ::
	::                                         ::
	:::::::::::::::::::::::::::::::::::::::::::::
	*/
	function FXLake ( $im, $NUM_FRAMES, $FLAG ) {
		$this->_101 = $NUM_FRAMES <= 0 ? 12 : $NUM_FRAMES;
		if ( strToLower ( $FLAG ) == "bin" ) {
			$this->_001 = imageCreateFromString ( $im );
		}
		else if ( strToLower ( $FLAG ) == "url" ) {
			$this->_001 = imageCreateFromGif ( $im );
		}
		else {
			print "Unintelligible flag: '$FLAG'";
			exit ( 0 );
		}
		$this->_002 = imageSx ( $this->_001 );
		$this->_003 = imageSy ( $this->_001 );
		$this->_004 = imageCreateTrueColor ($this->_002, $this->_003 );
		for ( $i = 0; $i < $this->_003; $i++ ) {
			imagecopy ( $this->_004, $this->_001, 0, $this->_003 - $i, 0, $i, $this->_002, 1 );
		}
	}
	/*
	:::::::::::::::::::::::::::::::::::::::::::::
	::                                         ::
	::            Frame Constructor            ::
	::                                         ::
	:::::::::::::::::::::::::::::::::::::::::::::
	*/
	function MakeFrame ( $i ) {
		$_102 = ( $this->PID * $i ) / $this->_101;
		$_103 = imageCreateTrueColor ( $this->_002, $this->_003 );
		for ( $j = 0; $j < $this->_003; $j++ ) {
			$_104 = ( ( $this->_003 / 14 ) * ( $j + 28.0 ) * sin ( ( ( $this->_003 / 14)
						* ( $this->_003 - $j ) ) / ( $j + 1 ) + $_102 ) / $this->_003 );
			if ( $j < -$_104 ) {
				imagecopy ( $_103, $this->_004, 0, $j, 0, $j, $this->_002, 1 );
			}
			else {
				imagecopy ( $_103, $this->_004, 0, $j, 0, $j + $_104, $this->_002, 1 );
			}
		}
		$_105 = imageCreateTrueColor ( $this->_002, ( 2 * $this->_003 ) - 18 );
		imagecopy ( $_105, $_103, 0, $this->_003 - 4, 0, 0, $this->_002, $this->_003 );
		imagecopy ( $_105, $this->_001, 0, 0, 0, 0, $this->_002, $this->_003 );
		imageDestroy ( $_103 );
		return $_105;
	}
	/*
	:::::::::::::::::::::::::::::::::::::::::::::
	::                                         ::
	::          A N I M A T E D  O U T         ::
	::                                         ::
	:::::::::::::::::::::::::::::::::::::::::::::
	*/
	function AnimatedOut ( ) {

		for ( $i = 0; $i < ANIM_FRAMES; $i++ ) {
			Ob_Start ( );
			imageGif ( FXLake::MakeFrame( $i ) );

			$f_arr [ ] = Ob_Get_Contents ( );
			$d_arr [ ] = ANIM_DELAYS;

			Ob_End_Clean ( );
		}
		$GIF = new GIFEncoder ( $f_arr, $d_arr, 0, 2, -1, -1, -1, "bin" );
		return ( $GIF->GetAnimation ( ) );
	}
}
?>
Return current item: FXLake effect