function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string) { global $f, $m; $t = new SWFText(); $t->setFont($f); $t->setColor($r, $g, $b, $a); $t->setHeight(96); $t->moveTo(-$t->getWidth($string) / 2, 32); $t->addString($string); $i = $m->add($t); $i->rotateTo($rot); $i->moveTo($x, $y); $i->scale($scale, $scale); return $i; }
/** * Writes text * * Parameter array: * 'x' : int X-point of text * 'y' : int Y-point of text * 'text' : string The text to add * 'color' : mixed [optional] The color of the text * * @param array $params Parameter array * * @todo Vertical alignment * @return void */ function addText($params) { $x0 = $this->_getX($params['x']); $y0 = $this->_getY($params['y']); $text = str_replace("\r", '', $params['text']); $color = isset($params['color']) ? $params['color'] : false; $textHeight = $this->textHeight($text); $alignment = isset($params['alignment']) ? $params['alignment'] : false; if (!is_array($alignment)) { $alignment = array('vertical' => 'top', 'horizontal' => 'left'); } if (!isset($alignment['vertical'])) { $alignment['vertical'] = 'top'; } if (!isset($alignment['horizontal'])) { $alignment['horizontal'] = 'left'; } if ($color === false && isset($this->_font['color'])) { $color = $this->_font['color']; } if ($color == 'transparent') { return; } if (strpos($this->_font['file'], '.') === false) { $this->_font['file'] = IMAGE_CANVAS_SYSTEM_FONT_PATH . $this->_font['file'] . '.fdb'; } $textColor = $this->_color($color); $textOpacity = $this->_opacity($color); $lines = explode("\n", $text); foreach ($lines as $line) { $x = $x0; $y = $y0; $y0 += $textHeight + 2; $width = $this->textWidth($line); $height = $this->textHeight($line); if ($alignment['horizontal'] == 'right') { $x -= $width; } else { if ($alignment['horizontal'] == 'center') { $x -= $width / 2; } } $font = new SWFFont($this->_font['file']); $text = new SWFText(); $text->setFont($font); $text->moveTo($x, $y + $this->_font['size']); $text->setColor($textColor[0], $textColor[1], $textColor[2], $textOpacity); $text->setHeight($this->_font['size']); $text->addString($line); $this->_canvas->add($text); } parent::addText($params); }
/* 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"); $txt = new SWFText(); /* build the title */ $txt->setFont($fnt); $txt->setHeight($fontsize); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x, $dist_y); $txt->addString("Wind"); $txt->setColor(255, 0, 0); $txt->moveTo($dist_x + 50, $dist_y); $txt->addString("Direction"); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x + 130, $dist_y); $txt->addString("and"); $txt->setColor(0, 0, 255); $txt->moveTo($dist_x + 170, $dist_y); $txt->addString("Speed (mph)"); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x + 285, $dist_y); $txt->addString("vs. Time"); /* place tics along the x axis, put in vertical graph lines, and label x axis tics.
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $mediadir = $srcdir . "/../Media"; $m = new SWFMovie(); $f = new SWFFont($mediadir . "/font01.fdb"); $t = new SWFText(1); $t->setFont($f); $t->setHeight(20); $t->setColor(0x0, 0x0, 0xff); $t->moveTo(100, 100); $t->addString("Static Text"); $tf = new SWFTextField(SWFTEXTFIELD_NOEDIT); $tf->setFont($f); $tf->setHeight(20); $tf->setColor(0xff, 0x0, 0x0); $tf->addString("Readonly Textfield"); $m->add($t); $it = $m->add($tf); $it->moveTo(100, 120); $m->nextFrame(); /* end of frame 1 */ $m->save("test05.swf");
$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); // make a button $b[$x] = new SWFButton(); $b[$x]->addShape($hit, SWFBUTTON_HIT); $b[$x]->addShape($t, SWFBUTTON_OVER | SWFBUTTON_UP | SWFBUTTON_DOWN); $b[$x++]->addAction(new SWFAction("getURL('{$link}','_new');"), SWFBUTTON_MOUSEUP); } // display them for ($x = 0; $x < $itemCount; $x++) { $i = $m->add($b[$x]); $i->moveTo($width / 2, 30); for ($j = 0; $j <= 30; ++$j) { $i->scaleTo(sqrt(sqrt($j / 30))); $i->multColor(1.0, 1.0, 1.0, $j / 30); $m->nextFrame();
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $mediadir = $srcdir . "/../Media"; $m = new SWFMovie(); /* SWF_DEFINEFONT2 */ $f2 = new SWFFont($mediadir . "/font01.fdb"); /* init font 2 code table*/ /* SWF_DEFINETEXT */ $character1 = new SWFText(1); $character1->setFont($f2); $character1->setHeight(10); $character1->setColor(0x0, 0x0, 0x0); $character1->moveTo(10, 100); $character1->addString("The quick brown fox jumps over the lazy dog. 1234567890"); /* SWF_PLACEOBJECT2 */ $i1 = $m->add($character1); $i1->setDepth(1); /* PlaceFlagHasMatrix */ /* SWF_SHOWFRAME */ $m->nextFrame(); /* end of frame 1 */ /* SWF_END */ $m->save("test01.swf");
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $mediadir = $srcdir . "/../Media"; $m = new SWFMovie(); ming_setscale(1.0); /* SWF_DEFINEFONT2 */ $f2 = new SWFFont($mediadir . "/test.ttf"); /* init font 2 code table*/ /* SWF_DEFINETEXT */ $character1 = new SWFText(1); $character1->setFont($f2); $character1->setHeight(400); $character1->setColor(0x0, 0x0, 0x0); $character1->moveTo(30234, 0); $character1->addString("|"); /* SWF_PLACEOBJECT2 */ $i1 = $m->add($character1); $i1->setDepth(1); /* PlaceFlagHasMatrix */ /* SWF_SHOWFRAME */ $m->nextFrame(); /* end of frame 1 */ /* SWF_END */ $m->save("test03.swf");
/* 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"); $txt = new SWFText(); /* build the title */ $txt->setFont($fnt); $txt->setHeight($fontsize); $txt->setColor(0, 0, 255); $txt->moveTo($dist_x, $dist_y); $txt->addString("Rainfall (inches)"); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x + 135, $dist_y); $txt->addString("vs. Time"); /* place tics along the x axis, put in vertical graph lines, and label x axis tics. */ $tics = 10; $ticHt = 5; /* Height of text label -- use this to drop the H:M of every other time label by $labHt pixels to improve readibility. */ $labHt = 5; $dtic = ($row_count - 1) / $tics; $labelSize = 14;
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $mediadir = $srcdir . "/../Media"; $m = new SWFMovie(); ming_setscale(1.0); /* SWF_DEFINEFONT2 */ $f2 = new SWFFont($mediadir . "/test.ttf"); /* init font 2 code table*/ /* SWF_DEFINETEXT */ $character1 = new SWFText(1); $character1->setFont($f2); $character1->setHeight(400); $character1->setColor(0x0, 0x0, 0x0); $character1->moveTo(2000, 2000); $character1->addString("The quick brown fox jumps over the lazy dog. 1234567890"); /* SWF_PLACEOBJECT2 */ $i1 = $m->add($character1); $i1->setDepth(1); /* PlaceFlagHasMatrix */ /* SWF_SHOWFRAME */ $m->nextFrame(); /* end of frame 1 */ /* SWF_END */ $m->save("test02.swf");
} for ($i = 0; $i < $count; ++$i) { $t = new SWFText(); $t->setFont($f); $t->setColor($r, $g, $b); $my_height = $height; while (true) { $t->setHeight($my_height); if ($t->getWidth($titles[$i]) < 0.9 * $width) { break; } $my_height = 0.9 * $my_height; } $x[$i] = 5; $y[$i] = ($height - $font_height) / 2; $t->moveTo($x[$i], $y[$i]); $t->addUTF8String($titles[$i]); $buttons[$i] = new SWFButton(); $buttons[$i]->addShape($hit, SWFBUTTON_HIT); $buttons[$i]->addShape($t, SWFBUTTON_OVER | SWFBUTTON_UP | SWFBUTTON_DOWN); $buttons[$i]->addAction(new SWFAction("getURL('" . $links[$i] . "', '');"), SWFBUTTON_MOUSEUP); } for ($n = 0; $n < 4; ++$n) { for ($i = 0; $i < $count; ++$i) { $infunc = $infuncs[rand(0, count($infuncs) - 1)]; $instance = $infunc($m, $buttons[$i], $x[$i], $y[$i]); for ($j = 0; $j < 60; ++$j) { $m->nextFrame(); } $outfunc = $outfuncs[rand(0, count($outfuncs) - 1)]; $outfunc($m, $buttons[$i], $instance, $x[$i], $y[$i]);
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $mediadir = $srcdir . "/../Media"; $m = new SWFMovie(); $f2 = new SWFFont($mediadir . "/font01.fdb"); $f3 = new SWFFont($mediadir . "/test.ttf"); $t = new SWFText(2); $t->setFont($f2); $t->setHeight(20); $t->setColor(0x0, 0x0, 0x0, 0xff); $t->moveTo(10, 20); $t->addString("abc"); $t->moveTo(0, 40); $t->addString("bca"); $t->moveTo(60, 0); $t->addString("cab"); $m->add($t); $m->nextFrame(); $m->save("test03.swf");
/* 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"); $txt = new SWFText(); /* build the title */ $txt->setFont($fnt); $txt->setHeight($fontsize); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x, $dist_y); $txt->addString("Outdoor"); $txt->setColor(255, 0, 0); $txt->moveTo($dist_x + 75, $dist_y); $txt->addString("Temp (F)"); $txt->setColor(0, 190, 0); $txt->moveTo($dist_x + 165, $dist_y); $txt->addString("Humidity"); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x + 245, $dist_y); $txt->addString("and"); $txt->setColor(0, 0, 255); $txt->moveTo($dist_x + 285, $dist_y); $txt->addString("Indoor Pressure (inHg)"); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x + 475, $dist_y);