function box($w, $h) { global $g; $s = new SWFShape(); $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); $f->scaleTo(0.05); $s->setRightFill($f); //$s->setRightFill($s->addFill(255,255,255)); $s->movePenTo(0, 0); $s->drawLineTo($w, 0); $s->drawLineTo($w, -$h); $s->drawLineTo(0, -$h); $s->drawLineTo(0, 0); return $s; }
function makeImgMovie($imgFile) { //Make sure this file is an actual jpg file if (is_file($imgFile) && ereg("\\.jpg\$", $imgFile)) { //Launch Flash $movie = new swfMovie(); $movie->setBackground(255, 255, 255); //Import a bitmap $b = new SWFBitmap(fOpen($imgFile, "rb")); //Get it's width and height $w = $b->getWidth(); $h = $b->getHeight(); //Make stage as big as the width and height of our bitmap $movie->setDimension($w, $h); //Convert Bitmap to a shape for Flash. //This process is automated upon import in Flash, but with //Ming we have have to do it ourselves. I see it as more control:) $s = new SWFShape(); $f = $s->addFill($b); $s->setRightFill($f); //draw corners for the bitmap shape $s->drawLine($w, 0); $s->drawLine(0, $h); $s->drawLine(-$w, 0); $s->drawLine(0, -$h); //CreateEmptyMovieclip $p = new SWFSprite(); //add our bitmap shape to this movieclip $p->add($s); $p->nextFrame(); //Add this movieclip to our main movie's timeline //Much like dragging a symbol from the library in Flash. $i = $movie->add($p); //Give this instance a name.. let's call it mImg as in movie image $i->setName("mImg"); //Output the movie.. Ctrl+Enter! // header("Content-Type:application/x-shockwave-flash"); $movie->output(); } //End if }
/** * Draw a polygon with a background * * @param mixed $background Background (can be a color or a gradient) * @param Polygon A polygon */ function filledPolygon($background, &$polygon) { $shape = new SWFShape(); if (is_a($background, 'awColor')) { list($red, $green, $blue, $alpha) = $this->getColor($background); $shape->setRightFill($red, $green, $blue, $alpha); } elseif (is_a($background, 'awGradient')) { list($flashGradient, $style) = $this->getGradient($background); $fill = $shape->addFill($flashGradient, $style); list($xMin, $xMax) = $polygon->getBoxXRange(); list($yMin, $yMax) = $polygon->getBoxYRange(); if ($background->angle === 0) { $fill->scaleTo(($yMax - $yMin) / 1600); } else { $fill->scaleTo(($xMax - $xMin) / 1600); } $fill->moveTo($xMin + ($xMax - $xMin) / 2, $yMin + ($yMax - $yMin) / 2); $shape->setRightFill($fill); } $points = $polygon->all(); $count = count($points); if ($count > 1) { $prev = $points[0]; $shape->movePenTo($prev->x, $prev->y); for ($i = 1; $i < $count; $i++) { $current = $points[$i]; $shape->drawLineTo($current->x, $current->y); } // Close the polygon $shape->drawLineTo($prev->x, $prev->y); $this->movie->add($shape); } }
/** * Set the fill and line properties for a SWWFShape according to the * given parameters. * * @param SWFShape $shape * @param ezcGraphColor $color * @param mixed $thickness * @param mixed $filled * @return void */ protected function setShapeColor(SWFShape $shape, ezcGraphColor $color, $thickness, $filled) { if ($filled) { switch (true) { case $color instanceof ezcGraphLinearGradient: $gradient = new SWFGradient(); $gradient->addEntry(0, $color->startColor->red, $color->startColor->green, $color->startColor->blue, 255 - $color->startColor->alpha); $gradient->addEntry(1, $color->endColor->red, $color->endColor->green, $color->endColor->blue, 255 - $color->endColor->alpha); $fill = $shape->addFill($gradient, SWFFILL_LINEAR_GRADIENT); // Calculate desired length of gradient $length = sqrt(pow($color->endPoint->x - $color->startPoint->x, 2) + pow($color->endPoint->y - $color->startPoint->y, 2)); $fill->scaleTo($this->modifyCoordinate($length) / 32768, $this->modifyCoordinate($length) / 32768); $fill->rotateTo(rad2deg(asin(($color->endPoint->x - $color->startPoint->x) / $length) + 180)); $fill->moveTo($this->modifyCoordinate(($color->startPoint->x + $color->endPoint->x) / 2), $this->modifyCoordinate(($color->startPoint->y + $color->endPoint->y) / 2)); $shape->setLeftFill($fill); break; case $color instanceof ezcGraphRadialGradient: $gradient = new SWFGradient(); $gradient->addEntry(0, $color->startColor->red, $color->startColor->green, $color->startColor->blue, 255 - $color->startColor->alpha); $gradient->addEntry(1, $color->endColor->red, $color->endColor->green, $color->endColor->blue, 255 - $color->endColor->alpha); $fill = $shape->addFill($gradient, SWFFILL_RADIAL_GRADIENT); $fill->scaleTo($this->modifyCoordinate($color->width) / 32768, $this->modifyCoordinate($color->height) / 32768); $fill->moveTo($this->modifyCoordinate($color->center->x), $this->modifyCoordinate($color->center->y)); $shape->setLeftFill($fill); break; default: $fill = $shape->addFill($color->red, $color->green, $color->blue, 255 - $color->alpha); $shape->setLeftFill($fill); break; } } else { $shape->setLine($this->modifyCoordinate($thickness), $color->red, $color->green, $color->blue, 255 - $color->alpha); } }
} $devices = $DB->GetAllByKey('SELECT n.id, n.name, n.location, MAX(lastonline) AS lastonline FROM netdevices n LEFT JOIN vnodes ON (n.id = netdev) GROUP BY n.id, n.name, n.location', 'id'); foreach ($devicemap as $deviceid => $device) { $button = new SWFButton(); $squareshape = new SWFShape(); $celx = $device['x']; $cely = $device['y']; $px = $celx * $cellw + $celllmargin; $py = $cely * $cellh + $celltmargin; $d = $devices[$deviceid]; if ($d['lastonline']) { if (time() - $d['lastonline'] > ConfigHelper::getConfig('phpui.lastonline_limit')) { $myfill = $squareshape->addFill($im_d_off, SWFFILL_TILED_BITMAP); } else { $myfill = $squareshape->addFill($im_d_on, SWFFILL_TILED_BITMAP); } } else { $myfill = $squareshape->addFill($im_d_unk, SWFFILL_TILED_BITMAP); } $myfill->scaleto(9, 9); $squareshape->setRightFill($myfill); $squareshape->drawLine(15, 0); $squareshape->drawLine(0, 15); $squareshape->drawLine(-15, 0); $squareshape->drawLine(0, -15); $button->addShape($squareshape, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER); $button->addAction(new SWFAction("this.getURL('?m=netdevinfo&id=" . $deviceid . "');"), SWFBUTTON_MOUSEDOWN); // press
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $m = new SWFMovie(9); $m->setBackground(0xcc, 0xcc, 0xcc); $s = new SWFShape(); $img = new SWFBitmap($srcdir . "/../Media/image01.dbl"); $fill = $s->addFill($img, SWFFILL_TILED_BITMAP); $s->setRightFill($fill); $w = $img->getWidth(); $h = $img->getHeight(); $s->drawLine($w, 0); $s->drawLine(0, $h); $s->drawLine(-$w, 0); $s->drawLine(0, -$h); $cm = array(); for ($i = 0; $i < 20; $i++) { $cm[$i] = 0.1; } $cmf = new SWFFilterMatrix(5, 4, $cm); $filter = new SWFFilter(SWFFILTER_TYPE_COLORMATRIX, $cmf); $bu = new SWFButton(); $bu->addCharacter($s, SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN); $item = $m->add($bu); $item->addFilter($filter); $m->save("test05.swf");
<?php require 'XML/RSS.php'; $r =& new XML_RSS('slashdot.rdf'); $r->parse(); $allItems = $r->getItems(); $itemCount = count($allItems); $width = 1000; $m = new SWFMovie(); $m->setDimension($width, 70); $m->setBackground(0xcf, 0xcf, 0xcf); $f = new SWFFont("../../../fonts/Techno.fdb"); $hit = new SWFShape(); $hit->setRightFill($hit->addFill(0, 0, 0)); $hit->movePenTo(-($width / 2), -30); $hit->drawLine($width, 0); $hit->drawLine(0, 60); $hit->drawLine(-$width, 0); $hit->drawLine(0, -60); $x = 0; // build the buttons foreach ($allItems as $Item) { $title = $Item['title']; $link = $Item['link']; // get the text $t = new SWFText(); $t->setFont($f); $t->setHeight(50); $t->setColor(0, 0, 0); $t->moveTo(-$f->getWidth($title) / 2, 25); $t->addString($title);
<?php $s = new SWFShape(); $s->setLine(4, 0x7f, 0, 0); $s->setRightFill($s->addFill(0xff, 0, 0)); $s->movePenTo(10, 10); $s->drawLineTo(310, 10); $s->drawLineTo(310, 230); $s->drawCurveTo(10, 230, 10, 10); $m = new SWFMovie(); $m->setDimension(320, 240); $m->setRate(12.0); $m->add($s); $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); $m->output();
<?php $s = new SWFShape(); $fp = fopen('../../intro/php-big.jpg', 'r'); $jpg = new SWFBitmap($fp); $w = $jpg->getWidth(); $h = $jpg->getHeight(); $f = $s->addFill($jpg); $f->moveTo(-$w / 2, -$h / 2); $s->setRightFill($f); $s->movePenTo(-$w / 2, -$h / 2); $s->drawLine($w, 0); $s->drawLine(0, $h); $s->drawLine(-$w, 0); $s->drawLine(0, -$h); $p = new SWFSprite(); $i = $p->add($s); for ($step = 0; $step < 360; $step += 2) { $p->nextFrame(); $i->rotate(-2); } $m = new SWFMovie(); $i = $m->add($p); $i->moveTo(230, 120); $m->setRate(100); $m->setDimension($w * 1.8, $h * 1.8); header('Content-type: application/x-shockwave-flash'); $m->output(6);
<?php ming_useswfversion(4); $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(-500, -500); $s->drawLineTo(500, -500); $s->drawLineTo(500, 500); $s->drawLineTo(-500, 500); $s->drawLineTo(-500, -500); $p = new SWFSprite(); $i = $p->add($s); $i->setDepth(1); $p->nextFrame(); for ($n = 0; $n < 5; ++$n) { $i->rotate(-15); $p->nextFrame(); } $m = new SWFMovie(); $m->setBackground(0xff, 0xff, 0xff); $m->setDimension(6000, 4000); $i = $m->add($p); $i->setDepth(1); $i->moveTo(-500, 2000); $i->setName("box"); $m->add(new SWFAction("/box.x += 3;")); $m->nextFrame(); $m->add(new SWFAction("gotoFrame(0); play();")); $m->nextFrame(); header('Content-type: application/x-shockwave-flash');
private static function _outFlash() { if (!class_exists('SWFBitmap')) { return false; } self::_getCodeLenth(); self::_creatImage(); self::_setRandBackground(); self::_creatBackground(); //self::_setPicBackground(); self::_setRandFont(); self::_setRandGraph(); self::_writeImage(); self::_setRandDistortion(); $_tmpPath = Wind::getRealDir('DATA:tmp.'); $_tmp = $_tmpPath . WindUtility::generateRandStr(8) . '.png'; imagepng(self::$_image, $_tmp); if (!WindFile::isFile($_tmp)) { return false; } imagedestroy(self::$_image); $bit = new SWFBitmap($_tmp); $shape = new SWFShape(); $shape->setRightFill($shape->addFill($bit)); $shape->drawLine($bit->getWidth(), 0); $shape->drawLine(0, $bit->getHeight()); $shape->drawLine(-$bit->getWidth(), 0); $shape->drawLine(0, -$bit->getHeight()); $movie = new SWFMovie(); $movie->setDimension($bit->getWidth(), $bit->getHeight()); $flash = $movie->add($shape); header("Pragma:no-cache"); header("Cache-control:no-cache"); header('Content-type: application/x-shockwave-flash'); $movie->output(); WindFolder::clear($_tmpPath); }
/** * Draw a rectangle filled with a gradient from $color1 to * $color2. * * @param integer $x The left x-coordinate of the rectangle. * @param integer $y The top y-coordinate of the rectangle. * @param integer $width The width of the rectangle. * @param integer $height The height of the rectangle. * @param string $color The outline color of the rectangle. * @param string $fill1 The name of the start color for the gradient. * @param string $fill2 The name of the end color for the gradient. */ function gradientRectangle($x, $y, $width, $height, $color = 'black', $fill1 = 'black', $fill2 = 'white') { $s = new SWFShape(); if ($color != 'none') { $color = $this->allocateColor($color); $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); } $fill1 = $this->allocateColor($fill1); $fill2 = $this->allocateColor($fill2); $gradient = new SWFGradient(); $gradient->addEntry(0.0, $fill1['red'], $fill1['green'], $fill1['blue'], $fill1['alpha']); $gradient->addEntry(1.0, $fill2['red'], $fill2['green'], $fill2['blue'], $fill2['alpha']); $f = $s->addFill($gradient, SWFFILL_LINEAR_GRADIENT); $f->scaleTo($width / $this->_width); $f->moveTo($x, $y); $s->setRightFill($f); $verts[0] = array('x' => $x, 'y' => $y); $verts[1] = array('x' => $x + $width, 'y' => $y); $verts[2] = array('x' => $x + $width, 'y' => $y + $height); $verts[3] = array('x' => $x, 'y' => $y + $height); $first_done = false; foreach ($verts as $vert) { if (!$first_done) { $s->movePenTo($vert['x'], $vert['y']); $first_done = true; $first_x = $vert['x']; $first_y = $vert['y']; } $s->drawLineTo($vert['x'], $vert['y']); } $s->drawLineTo($first_x, $first_y); return $this->_movie->add($s); }