Una piccola libreria per convertire i tracciati di Gimp 1 in SWFShape da usare con PHP-Ming

LampoWeb è una piccola libreria che ho scritto qualche tempo fa in PHP. Raccoglie alcune utili funzioni per convertire i tracciati fatti con la versione 1 di Gimp (la versione 2 usa il formato SVG) in oggetti SWFShape da usare con le estensioni ming di PHP.

La home page del progetto LampoWeb

La home page del progetto ming

Code samples

Questo codice produce la homepage del progetto LampoWeb. < ?php /** * Simple test page for php-ming * @author Alessandro Pasotti */ require "lampoweb.inc"; $colors['up'] = $colorList['SkyBlue3']; $colors['hit'] = $colorList['SkyBlue1']; $colors['over'] = $colorList['SkyBlue1']; $colors['text'] = $colorList['White']; $colors['down'] = $colorList['Firebrick3']; $colors['fill1'] = $colorList['Firebrick3']; $colors['fill2'] = $colorList['White']; $colors['background'] = $colorList['Lavender']; $xMax = 800; $yMax = 600; $frames = 200; $cp = new point($xMax/2,$yMax/2); $ul = new point(0,0); $lr = new point($xMax,$yMax); $ur = new point ($lr->x , $ul->y); $ll = new point ($ul->x , $lr->y); //var_dump ($colors); ming_setcubicthreshold(10); $myShape = new SWFShape(); $myShape->setLine(0,0,0,0); $myFill = $myShape->addFill($colors['fill1']->getDecR(), $colors['fill1']->getDecG(), $colors['fill1']->getDecB()); $myShape->setRightFill($myFill); $myMovie = new SWFMovie(); $myMovie->setDimension($xMax,$yMax); $myMovie->setBackground($colors['background']->getDecR(), $colors['background']->getDecG(), $colors['background']->getDecB()); // light blue $myShape2 = new SWFShape(); $myShape2->setLine(0,0,0,0); $myFill2 = $myShape2->addFill($colors['hit']->getDecR(), $colors['hit']->getDecG(), $colors['hit']->getDecB()); $myShape2->setRightFill($myFill2); vecLoad ('spirale.vec' , &$myShape2 , 1 , $xMax * 0.6); $lampoweb = ShapeRotateAt(&$myShape2, &$myMovie, $cp , -360 , $frames*2); $lampoweb->setName('spirale'); $mySprite = new SWFSprite(); vecLoad ('lampoweb.vec' , &$myShape , 1 , $xMax * 0.8); for($i=0; $i<9; ++$i){ $infunc = $infuncs[$i]; $instance = $infunc($mySprite, $myShape , $cp); for($j=0; $j<30; ++$j) $mySprite->nextFrame(); $outfunc = $outfuncs[$i]; $outfunc($mySprite, $myShape, $instance, $cp ); } $lmp = $myMovie->add($mySprite); $lmp->setName('lampoweb'); $dimension = new point(700,20); $point = new point(50,500); $menu[] = array( 'text' => 'Browse Itopen.net' , 'action' => "getUrl('http://www.itopen.net', '_top');"); $menu[] = array( 'text' => 'View Acqualba.it' , 'action' => "getUrl('http://www.acqualba.it', '_top');"); $menu[] = array( 'text' => 'Stop' , 'action' => "spirale.stop();lampoweb.stop();"); $menu[] = array( 'text' => 'Start' , 'action' => " spirale.play(); lampoweb.play(); lampoweb._visible = true; "); $menu[] = array( 'text' => 'Clear' , 'action' => "lampoweb._visible = false;"); putSWFHorizontalMenu ($myMovie , $dimension , $point , 0.1 , $menu , "Techno.fdb" , $colors, 'center', 1); $myMovie->save('lampoweb.swf'); $bg = $colors['background']->getColor(); $top = < << XXX

XXX; echo $top; ?>