note 19862 modified in function.swfgradient by danbrown

From: Date: Fri, 28 Nov 2008 21:43:14 +0000
Subject: note 19862 modified in function.swfgradient by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147259@lists.php.net to get a copy of this message
Gradient fills are implemented in SWF as a color ramp, mapped onto a square from (-16384, -16384) to (16384, 16384) TWIPS. The following code creates a movie, displaying a square with a gradient fill, correctly scaled to the size of the shape. <?php //Set the scale to TWIPS rather than PIXELS ming_setscale(1.0); //Create the movie $m = new SWFMovie(); $m->setRate(12.0); $m->setDimension(400,400); $m->setBackground(0xff, 0xff, 0xff); //Width and height of rectangle $sx = 300; $sy = 300; //Create rectangle $s = new SWFShape(); //Gradient file stuff here... $g = new SWFGradient(); $g->addEntry(0.0, 0x00, 0x00, 0xff); // Start off Blue $g->addEntry(1.0, 0xff, 0xff, 0x00); // Finish off Yellow // Add gradient fill to the shape $f = $s->addFill($g); //Centre the gradient fill against the rectangle $f->moveTo($sx/2, $sy/2); //Scale it to the shape, so that the entire gradient fits inside the shape $f->scaleTo($sx/32768, 1); // Set the shapes fill to be the added gradient fill $s->setRightFill($f); //Draw the rectangle $s->drawLine($sx, 0); $s->drawLine(0, $sy); $s->drawLine(-$sx, 0); $s->drawLine(0, -$sy); //Add the shape to the movie $sh = $m->add($s); $sh->moveTo(50, 50); // Output the movie header("Content-type: application/x-shockwave-flash"); $m->output(); ?> More info about this can be obtained from http://www.openswf.org/spec/SWFfilereference.html#h4FillTypes --was-- Gradient fills are implemented in SWF as a color ramp, mapped onto a square from (-16384, -16384) to (16384, 16384) TWIPS. The following code creates a movie, displaying a square with a gradient fill, correctly scaled to the size of the shape. <?php //Set the scale to TWIPS rather than PIXELS ming_setscale(1.0); //Create the movie $m = new SWFMovie(); $m->setRate(12.0); $m->setDimension(400,400); $m->setBackground(0xff, 0xff, 0xff); //Width and height of rectangle $sx = 300; $sy = 300; //Create rectangle $s = new SWFShape(); //Gradient file stuff here... $g = new SWFGradient(); $g->addEntry(0.0, 0x00, 0x00, 0xff); // Start off Blue $g->addEntry(1.0, 0xff, 0xff, 0x00); // Finish off Yellow // Add gradient fill to the shape $f = $s->addFill($g); //Centre the gradient fill against the rectangle $f->moveTo($sx/2, $sy/2); //Scale it to the shape, so that the entire gradient fits inside the shape $f->scaleTo($sx/32768, 1); // Set the shapes fill to be the added gradient fill $s->setRightFill($f); //Draw the rectangle $s->drawLine($sx, 0); $s->drawLine(0, $sy); $s->drawLine(-$sx, 0); $s->drawLine(0, -$sy); //Add the shape to the movie $sh = $m->add($s); $sh->moveTo(50, 50); // Output the movie header("Content-type: application/x-shockwave-flash"); $m->output(); ?> More info about this can be obtained from http://www.openswf.org/spec/SWFfilereference.html#h4FillTypes http://php.net/manual/en/function.swfgradient.php

« previous php.notes (#147259) next »