All pastes #1380958 Raw Edit

Agiofws

public php v1 · immutable
#1380958 ·published 2009-04-03 15:06 UTC
rendered paste body
<?/********************************************************************************* @ File: slideshow.php* @ Original date: October 2003 @ www16.brinkster.com/gazb/ming/* @ Version: 2.0* @ Summary:  grab jpgs from folders and create a swf slideshow* @ Updated:  small improvements and summary text* @ Copyright (c) 2003-2007, www.gazbming.com - all rights reserved.* @ Author: gazb.ming [[@]] gmail.com - www.gazbming.com * @ Released under GNU Lesser General Public License - http://www.gnu.org/licenses/lgpl.html********************************************************************************/// just put the directories with the jpgs here and compile$pathtojpgs= array();$pathtojpgs[0]= "/home/agiofws/la-boheme/test1/pngs/small/jpgs/";//$pathtojpgs[1]= "C:/ming/jpgs/";//$pathtojpgs[2]= "../mingwin/";//$pathtojpgs[3]= "/usr/share/Eterm/pix/tile/";//$pathtojpgs[4]= "./pics/";// some typical movie variablesMing_setScale(20.0000000);ming_useswfversion(6);$movie=new SWFMovie();$movie->setBackground(rand(0,0xFF),rand(0,0xFF),rand(0,0xFF));$movie->setRate(25); $movie->setDimension(1000,900);//// easing equation converted to php from Actionscript @ // http://www.robertpenner.com/easing_equations.as// use of which are subject to the license @// http://www.robertpenner.com/easing_terms_of_use.htmlfunction easeInQuad ($t, $b, $c, $d) {$t/=$d;	return $c*$t*$t + $b;};function easeOutQuad ($t, $b, $c, $d) {$t/=$d;	return -$c *($t)*($t-2) + $b;};// basic actionscript control of playback using mouse$strAction="if(!init){	init=true;	stopped=true;	controls = {		onMouseDown: function () {			if(!stopped){				stop();				stopped=true;			}else{				play();				stopped=false;			}		}	};	Mouse.addListener(controls);}";$movie->add(new SWFAction($strAction));// grab the jpgs$f = array();for($i=0;$i<count($pathtojpgs);$i++){	$f[$i] = array();	if ($handle = opendir($pathtojpgs[$i])) {		while (false !== ($file = readdir($handle))) { 			$tmp = explode(".",$file);			if($tmp[1]=="jpg"){				array_push ($f[$i],$pathtojpgs[$i] . $file);			}		}	}}closedir($handle);///////////////slideshow patch start//////////////////////////////// sort the jpgs into 'natural' order using natsort		//// (eg 1.jpg,a.jpg,b1.jpg,b2.jpg,b10.jpg,b12.jpg,b100.jpg)	//// see www.php.net Array docs for alts to natsort		//for($i=0;$i<count($f);$i++){					//// echo "original order\n";					//// print_r($f[0]);						//								//natsort($f[$i]); 	// sort that array			//$tmp=implode(",",$f[$i]); // ugly...				//$f[$i]=explode(",",$tmp); // but it works			//								//// echo "new order\n";						//// print_r($f[0]);						//}								/////////////////slideshow patch end////////////////////////////////// add the jpgs to the movie with basic fade in/out$movie->nextFrame();for($i=0;$i<count($f);$i++){	for($k=0;$k<count($f[$i]);$k++){		$img = new SWFBitmap(fopen($f[$i][$k],"rb"));		$pic=$movie->add($img); 		$pic->moveTo( (275-$img->getwidth()/2),(200-$img->getheight()/2));		$transition=0.9;$cnt=1; $startpos=0; $offset=1; $duration=$transition;while($cnt<=$duration){$inc=easeInQuad ($cnt++, $startpos, $offset, $duration);			$pic->multColor(1,1,1,$inc);			$movie->nextFrame();		}		for($j=1;$j<=$transition*2;$j++){			$movie->nextFrame();		}$cnt=1; $startpos=1; $offset=-1; $duration=$transition;while($cnt<=$duration){$inc=easeOutQuad ($cnt++, $startpos, $offset, $duration);			$pic->multColor(1,1,1,$inc);			$movie->nextFrame();		}		$movie->remove($pic);	}}$movie->nextFrame();// save swf with same name as filename$swfname = basename(__FILE__,".php");$movie->save("$swfname.swf",9);?>