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; }
/** * 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); } }
foreach ($links as $link) { if (!isset($devicemap[$link['src']]['x']) || !isset($devicemap[$link['dst']]['x'])) { continue; } $src_celx = $devicemap[$link['src']]['x']; $src_cely = $devicemap[$link['src']]['y']; $dst_celx = $devicemap[$link['dst']]['x']; $dst_cely = $devicemap[$link['dst']]['y']; $src_px = $src_celx * $cellw + $celllmargin; $src_py = $src_cely * $cellh + $celltmargin; $dst_px = $dst_celx * $cellw + $celllmargin; $dst_py = $dst_cely * $cellh + $celltmargin; if (!$link['type']) { $connections->setLine(1, 0, 128, 0); $connections->movePenTo($src_px + 8, $src_py + 8); $connections->drawLineTo($dst_px + 8, $dst_py + 8); } else { $connections->setLine(1, 0, 200, 255); $connections->movePenTo($src_px + 8, $src_py + 8); $connections->drawLineTo($dst_px + 8, $dst_py + 8); } } } if ($nodemap) { foreach ($nodemap as $node) { $src_celx = $node['x']; $src_cely = $node['y']; $dst_celx = $devicemap[$node['device']]['x']; $dst_cely = $devicemap[$node['device']]['y']; $src_px = $src_celx * $cellw + $celllmargin; $src_py = $src_cely * $cellh + $celltmargin;
//$grey = (128,128,128); //$ltGrey = (192,192,192); //$ltrGrey = (224,224,224); /* For a 100 x 100 image: (0,0) is the upper left hand corner, (100,100) is the lower right hand corner. */ /* keep the data within a bounding box */ $gxb = $gx * 0.8; $dx = ($gx - $gxb) / 2; $gyb = $gy * 0.8; $dy = ($gy - $gyb) / 2; //imageRectangle($im,$dx,$dy,$dx+$gxb,$dy+$gyb,$ltGrey); /* draw the x axis */ $im->movePenTo($dx, $gyb + $dy); $im->drawLineTo($dx, $gyb + $dy); $im->drawLineTo($dx + $gxb, $gyb + $dy); /* draw the y axis */ $im->movePenTo($dx, $gyb + $dy); $im->drawLineTo($dx, $gyb + $dy); $im->drawLineTo($dx, $dy); /* generate the graph's title */ /* first get the font */ $fontsize = 18; /* set the distance, from the left, where the title will begin */ $dist_x = $dx + 30; /* set the distance, from the top, where the title will begin */ $dist_y = 15; /* create the font object and text object */ //$fnt=new SWFFont("Courier_New.fdb"); $fnt = new SWFFont("Arial.fdb");
#!/usr/bin/php -c. <?php $m = new SWFMovie(8); $shape1 = new SWFShape(); $shape1->setLine2(1, SWF_LINESTYLE_FLAG_HINTING, 0, 25, 0, 0, 128); $shape1->movePenTo(5, 5); $shape1->drawLineTo(50, 30); $item = $m->add($shape1); $m->nextFrame(); $m->replace($item, $shape1); $m->nextFrame(); $m->save("test02.swf");
#!/usr/bin/php -c. <?php $m = new SWFMovie(); $s = new SWFShape(); $s->setLine(1, 255, 0, 0, 255); $s->setRightFill(255, 255, 0, 255); $s->drawLine(100, 0); $s->drawLine(0, 40); $s->drawLineTo(0, 0); $b = new SWFButton(); $br1 = $b->addCharacter($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_OVER | SWFBUTTON_DOWN); $br2 = $b->addCharacter($s, SWFBUTTON_OVER | SWFBUTTON_DOWN); $br2->rotate(10); $br2->move(20, 0); $br3 = $b->addCharacter($s, SWFBUTTON_DOWN); $br3->rotate(20); $br3->move(40, 0); $d = $m->add($b); $d->moveTo(50, 100); $m->addExport($b, "ButtonExport"); $m->writeExports(); $m->nextFrame; $m->save("test02.swf"); ?>
<?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();
/** * Parameter array: * 'connect': bool [optional] Specifies whether the start point should be * connected to the endpoint (closed polygon) * or not (connected line) * 'fill' : mixed [optional] The fill color * 'line' : mixed [optional] The line color * 'url' : string [optional] Target URL * * @param array $params Parameter array * * @return void */ function polygon($params = array()) { $connectEnds = isset($params['connect']) ? $params['connect'] : false; $fillColor = isset($params['fill']) ? $params['fill'] : false; $lineColor = isset($params['line']) ? $params['line'] : false; $lineStyle = $this->_getLineStyle($lineColor); $fillStyle = $this->_getFillStyle($fillColor); $shape = new SWFShape(); if ($connectEnds) { $shape->setRightFill($fillStyle[0], $fillStyle[1], $fillStyle[2]); } $shape->setLine(0, $lineStyle[0], $lineStyle[1], $lineStyle[2]); $shape->movePenTo($this->_polygon[0]['X'], $this->_polygon[0]['Y']); foreach ($this->_polygon as $point) { $shape->drawLineTo($point['X'], $point['Y']); } if ($connectEnds) { $shape->drawLineTo($this->_polygon[0]['X'], $this->_polygon[0]['Y']); } if (isset($params['url'])) { $button = new SWFButton(); $button->addShape($shape, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER); $button->addAction(new SWFAction("getURL('{$params['url']}');"), SWFBUTTON_MOUSEUP); $this->_canvas->add($button); } else { $this->_canvas->add($shape); } parent::polygon($params); }
<?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');
#!/usr/bin/php -c. <?php $m = new SWFMovie(7); $s = new SWFShape(); $s->setLine(4, 25, 0, 0, 128); $s->movePenTo(5, 5); $s->drawLineTo(0, 10); $bl = new SWFBlur(5, 5, 2); $c = array(); $c["red"] = 0; $c['green'] = 0; $c['blue'] = 0; $c['alpha'] = 0xff; $f = new SWFFilter(SWFFILTER_TYPE_GLOW, $c, $bl, 1.0, SWFFILTER_MODE_INNER | SWFFILTER_MODE_KO); $bu = new SWFButton(); $bu->addShape($s, SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN); $item = $m->add($bu); $item->addFilter($f); $m->save("test03.swf");
<?php // Scaling Ming_setScale(20); srand(time()); // Creates the racket model $rm = new SWFShape(); $rm->setLine(5, 207, 96, 0); $rm->drawLineTo(0, 1); $rm->setLine(5, 255, 200, 0); $rm->movePenTo(0, 1); $rm->drawLineTo(0, 50); // Draws the white line at the middle of the screen $wl = new SWFShape(); $wl->setLine(8, 255, 255, 255); $wl->drawLineTo(0, 480); // Draws the "grass" border $gm = new SWFShape(); $gm->setLine(100, 48, 96, 48); $gm->drawLine(640, 0); // Draws the ball $bm = new SWFShape(); $bm->setLine(12, 255, 200, 0); $bm->drawLine(1, 1); // Creates a font $f = new SWFFont("arial.fdb"); // Writes the score for player $sp = new SWFTextField(); $sp->setBounds(100, 30); $sp->setName("pScore"); $sp->setFont($f);
#!/usr/bin/php -c. <?php $m = new SWFMovie(8); $shape1 = new SWFShape(); $shape1->setLine2(1, SWF_LINESTYLE_FLAG_HINTING, 0, 25, 0, 0, 128); $shape1->movePenTo(5, 5); $shape1->drawLineTo(50, 30); $shape2 = new SWFShape(); $shape2->setLine2(1, SWF_LINESTYLE_FLAG_HINTING, 0, 25, 100, 100, 255); $shape2->movePenTo(5, 5); $shape2->drawLineTo(50, 130); $item = $m->add($shape1); $m->nextFrame(); $m->replace($item, $shape2); $m->nextFrame(); $m->save("test01.swf");
/** * 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); }