Exemple #1
0
 /**
  * Draw a rectangle with a background
  *
  * @param mixed $background Background (can be a color or a gradient)
  * @param $line Rectangle diagonale
  */
 function filledRectangle($background, $line)
 {
     list($p1, $p2) = $line->getLocation();
     // Common shape settings
     $shape = new SWFShape();
     $shape->setLine(0);
     if (is_a($background, 'awColor')) {
         // Get the Red, Green, Blue and Alpha values
         list($r, $g, $b, $a) = $this->getColor($background);
         $shape->setRightFill($r, $g, $b, $a);
     } else {
         if (is_a($background, 'awGradient')) {
             // Get the Gradient object as an SWFGradient one
             list($flashGradient, $style) = $this->getGradient($background);
             $fill = $shape->addFill($flashGradient, $style);
             // Angles between Artichow and Ming don't match.
             // Don't use abs() or vertical gradients get inverted.
             $angle = $background->angle - 90;
             $fill->rotateTo($angle);
             // Move the gradient based on the position of the rectangle we're drawing
             $centerX = min($p1->x, $p2->y) + abs($p1->x - $p2->x) / 2;
             $centerY = min($p1->y, $p2->y) + abs($p1->y - $p2->y) / 2;
             $fill->moveTo($centerX, $centerY);
             // Ming draws its gradients on a 1600x1600 image,
             // so we have to resize it.
             if ($angle === -90) {
                 $ratio = abs($p1->y - $p2->y) / 1600;
             } else {
                 $ratio = abs($p1->x - $p2->x) / 1600;
             }
             $fill->scaleTo($ratio);
             $shape->setRightFill($fill);
         }
     }
     // Set starting position
     $shape->movePenTo($this->x + round($p1->x), $this->y + round($p1->y));
     // Depending on the points' relative positions,
     // we have two drawing possibilities
     if ($p1->x <= $p2->x and $p1->y <= $p2->y or $p1->x >= $p2->x and $p1->y >= $p2->y) {
         $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p1->y));
         $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y));
         $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p2->y));
         $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p1->y));
     } else {
         $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p2->y));
         $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y));
         $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p1->y));
         $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p1->y));
     }
     $this->movie->add($shape);
 }
Exemple #2
0
 /**
  * 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);
     }
 }
Exemple #3
0
/* swfextract -p 1 -o character1.png $swf*/
$character1 = new SWFBitmap($mediadir . '/image01.png');
/* SWF_DEFINESHAPE3 */
/* Shape 2 (TYPE=3, RECT=-10,2010 -10,2010)*/
$character2 = new SWFShape();
/*1 fillstyle(s)*/
/* BitmapID: 1 */
$character2_f0 = $character2->addBitmapFill($character1, SWFFILL_CLIPPED_BITMAP);
$character2_f0->scaleTo(20.0);
/*1 linestyles(s)*/
$character2_l0_width = 20;
$character2_l0_red = 0x0;
$character2_l0_green = 0x0;
$character2_l0_blue = 0x0;
$character2_l0_alpha = 0xff;
/* StateLineStyle: 1 */
$character2->setLine($character2_l0_width, $character2_l0_red, $character2_l0_green, $character2_l0_blue, $character2_l0_alpha);
$character2->setRightFill($character2_f0);
$character2->drawLine(2000, 0);
$character2->drawLine(0, 2000);
$character2->drawLine(-2000, 0);
$character2->drawLine(0, -2000);
/* SWF_PLACEOBJECT2 */
$i1 = $m->add($character2);
$i1->setDepth(1);
/* PlaceFlagHasMatrix */
/* SWF_SHOWFRAME */
$m->nextFrame();
/* end of frame 1 */
/* SWF_END */
$m->save("test05.swf");
/* report the results (debugging) */
//echo "Processed $row_count rows<br>";
//echo "t_min=$t_min<br>";
//echo "t_max=$t_max<br>";
//echo "wndd_min=$wndd_min<br>";
//echo "wndd_max=$wndd_max<br>";
//echo "wnds_min=$wnds_min<br>";
//echo "wnds_max=$wnds_max<br>";
/* set the graph's x and y dimensions */
$gx = 800;
$gy = 240;
/* Time to create the $gx x $gy image */
/* first creat a blank image */
$im = new SWFShape();
/* use a 1 pixel width black pen */
$im->setLine(1, 0, 0, 0);
/* use a white background */
$mve = new SWFMovie();
$mve->setDimension($gx, $gy);
$mve->setBackground(255, 255, 255);
/* here's a small pallete to use for the graphs (RGB values) */
//black = (0,0,0);
//brown = (255,255,0);
//$red = (255,0,0);
//$yellow = (224,252,24);
//$green = (0,255,0);
//$drkGreen = (0,190,0);
//$blue = (0,0,255);
//$grey = (128,128,128);
//$ltGrey = (192,192,192);
//$ltrGrey = (224,224,224);
Exemple #5
0
 $links = $DB->GetAll('SELECT src, dst, type FROM netlinks');
 if ($links) {
     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'];
Exemple #6
0
 /**
  * Draw an ellipse
  *
  * Parameter array:
  * 'x'    : int X center point
  * 'y'    : int Y center point
  * 'rx'   : int X radius
  * 'ry'   : int Y radius
  * '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 ellipse($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $rx = $this->_getX($params['rx']);
     $ry = $this->_getY($params['ry']);
     // calculate scale factors
     $scaleX = 1.0;
     $scaleY = 1.0;
     $moveX = 0;
     $moveY = 0;
     if ($rx > $ry) {
         $scaleY = $ry / $rx;
         $moveY = $ry * (1 - $scaleY);
     } elseif ($rx < $ry) {
         $scaleX = $rx / $ry;
         $moveX = $rx * (1 - $scaleX);
     }
     $fillColor = isset($params['fill']) ? $params['fill'] : false;
     $lineColor = isset($params['line']) ? $params['line'] : false;
     $fillColor = $this->_getFillStyle($fillColor);
     $lineColor = $this->_getLineStyle($lineColor);
     $shape = new SWFShape();
     $shape->setRightFill($fillColor[0], $fillColor[1], $fillColor[2]);
     $shape->movePenTo($x, $y);
     $shape->setLine(1, $lineColor[0], $lineColor[1], $lineColor[2]);
     if (count($fillColor)) {
         $shape->setRightFill($fillColor[0], $fillColor[1], $fillColor[2]);
     }
     $shape->drawCircle(max($rx, $ry));
     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);
         $ellipse = $this->_canvas->add($button);
     } else {
         $ellipse = $this->_canvas->add($shape);
     }
     $ellipse->move($moveX, $moveY);
     $ellipse->scaleTo($scaleX, $scaleY);
     parent::ellipse($params);
 }
Exemple #7
0
#!/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");
?>
	
	

Exemple #8
0
 public function zeichneKoordinatenGitter($GridVisible = true, $XTickDistance = 40, $YTickDistance = 40)
 {
     $koord = new SWFShape();
     $koord->setLine(0, 212, 212, 212);
     $koord->movePenTo(0, 0);
     $koord->drawlineto($this->width - 1, 0);
     $koord->drawlineto($this->width, $this->height - 1);
     $koord->drawlineto(0, $this->height - 1);
     $koord->drawlineto(0, 0);
     $koordtext = new SWFText();
     $t = new SWFFont(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "fonts" . DIRECTORY_SEPARATOR . "FreeSans.fdb");
     $koordtext->setfont($t);
     $koordtext->setColor(212, 212, 212);
     // Skala Striche
     $i = $XTickDistance;
     while ($i < $this->width) {
         $koordtext->moveto($i, 20);
         $koordtext->addString($i);
         if ($GridVisible) {
             $koord->movePenTo($i, 0);
             $koord->drawlineto($i, $this->height);
         } else {
             $koord->movePenTo($i, 0);
             $koord->drawlineto($i, 20);
         }
         $i += $XTickDistance;
     }
     $i = $YTickDistance;
     while ($i < $this->height) {
         $koordtext->moveto(20, $i);
         $koordtext->addString($i);
         if ($GridVisible) {
             $koord->movePenTo(0, $i);
             $koord->drawlineto($this->width, $i);
         } else {
             $koord->movePenTo(0, $i);
             $koord->drawlineto(20, $i);
         }
         $i += $YTickDistance;
     }
     $this->SWFMovie->add($koordtext);
     $this->SWFMovie->add($koord);
     $this->SWFMovie->nextFrame();
 }
Exemple #9
0
<?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();
Exemple #10
0
#!/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");
Exemple #11
0
#!/usr/bin/php
<?php 
$m = new SWFMovie(8);
$shape = new SWFShape();
$gradient = new SWFGradient();
$gradient->addEntry(0, 255, 0, 0, 255);
$gradient->addEntry(0.25, 0x80, 0x20, 0x20, 0xff);
$gradient->addEntry(0.8, 0x40, 0x40, 0x40, 0xff);
$fill = $shape->addGradientFill($gradient, SWFFILL_LINEAR_GRADIENT);
#$fill->moveTo(-163, -163); # this is added by swftoscript, but is wrong
$shape->setLine(1, 0, 0, 0, 255);
$shape->setRightFill($fill);
$shape->drawLine(100, 0);
$shape->drawLine(0, 100);
$shape->drawLine(-100, 0);
$shape->drawLine(0, -100);
$m->add($shape);
$m->save("test08.swf");
Exemple #12
0
$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);
$sp->setColor(255, 255, 255);
$sp->addString("Player : 0");
// Writes the score for computer
$sc = new SWFTextField();
$sc->setBounds(100, 30);
$sc->setName("cScore");
$sc->setFont($f);
$y->setName('background');
$entire_key = new SWFSprite();
$key_label = new SWFTextField(SWFTEXTFIELD_NOSELECT);
$key_label->setBounds(150, 25);
$key_label->setFont($f);
$key_label->setHeight(14);
if ($space_plan_locked === false) {
    $key_label->setColor(0, 0, 0);
    $key_label_text = 'Merchandising Key';
} else {
    $key_label->setColor(255, 0, 0);
    $key_label_text = 'Plan Is Locked';
}
$key_label->addString($key_label_text);
$my_key_label_header = new SWFShape();
$my_key_label_header->setLine(1, 0, 0, 0);
$my_key_label_header->setRightFill(240, 240, 240);
$my_key_label_header->movePenTo(0, 5);
$my_key_label_header->drawLine(150, 0);
$my_key_label_header->drawLine(0, 25);
$my_key_label_header->drawLine(-150, 0);
$my_key_label_header->drawLine(0, -25);
$my_key_label = new SWFSprite();
$my_key_label->add($my_key_label_header);
$key_spr = $my_key_label->add($key_label);
$key_spr->moveTo(5, 7);
$my_key_label->nextFrame();
$my_key_label_sprite = $entire_key->add($my_key_label);
$my_key_label_sprite->setName('my_key_label');
$display_eqp_icons = true;
if ($display_eqp_icons) {
Exemple #14
0
 /**
  * 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);
 }