function getFlashDimensions($font, $title, $size) { $f = new SWFFont($font); $t = new SWFText(); $t->setFont($f); $t->setHeight($size); $dx = $t->getWidth($title) + 10; $dy = $size + 10; return array($dx, $dy); }
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; }
function text($string) { global $font; $t = new SWFText(); $t->setFont($font); $t->setColor(255, 255, 255); $t->setHeight(20); $t->addString($string); return $t; }
/** * 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); }
// 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); $sc->setColor(255, 255, 255); $sc->addString("Computer : 0"); // Write the "signature" $signature = new SWFText(); $signature->setFont($f); $signature->setColor(150, 150, 255); $signature->setHeight(9); $signature->addString("(c) Armel GRIGNON, october 2001 - See this script at mingshop.arpane.net"); // Now adds the objects to the movie // Creates the movie and the main sprite $m = new SWFMovie(); $m->setRate(96); $m->setBackground(207, 96, 0); $m->setDimension(640, 480); // Adds the two rackets (within sprites) $srp = new SWFSprite(); $srp_shape = $srp->add($rm); $srp->nextFrame(); $racket_player = $m->add($srp);
#!/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");
$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); // 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);
#!/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");
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(); }
private function getMingTextWidth(awText $text) { $font = $text->getFont(); if ($font->getExtension() === NULL) { $font->setExtension('fdb'); } $flashFont = new SWFFont(ARTICHOW_FONT . '/' . $font->name . '.' . $font->getExtension()); $flashText = new SWFText(); $flashText->setFont($flashFont); return $flashText->getWidth($text->getText()); }
/** * Draws a text string on the image in a specified location, with * the specified style information. * * @param string $text The text to draw. * @param integer $x The left x coordinate of the start of the text string. * @param integer $y The top y coordinate of the start of the text string. * @param string $font The font identifier you want to use for the text. * @param string $color The color that you want the text displayed in. * @param integer $direction An integer that specifies the orientation of the text. */ function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0) { $color = $this->allocateColor($color); if (!strncasecmp(PHP_OS, 'WIN', 3)) { $text = new SWFTextField(SWFTEXTFIELD_NOEDIT); } else { $text = new SWFText(); } $text->setColor($color['red'], $color['green'], $color['blue'], $color['alpha']); $text->addString($string); $text->setFont(new SWFFont($this->getFont($font))); $t = $this->_movie->add($text); $t->moveTo($x, $y); $t->rotate($direction); return $t; }
$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"); $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
$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"); $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)");
$t->addString($tText); $m->setDimension($dx, $dy); // Add the text to the movie and position it $i = $m->add($t); $i->moveTo((int) ($dx / 2) - $t->getWidth($tText) / 2, $dy - round($t->getDescent()) - ($dy - $tHeight) / 2); // Don't forget to add the button $m->add($b); break; case 'blurb': $m->setBackground(0xff, 0xff, 0xff); $m->setDimension($dx, $dy); $t = new SWFTextField(); if (!empty($objs[$coid]->title)) { $rgb = rgb($objs[$coid]->titleColor); $t->setColor($rgb[0], $rgb[1], $rgb[2]); $t = new SWFText(); $f = new SWFFont($objs[$coid]->font); $t->setFont($f); $t->setHeight(flash_fixsize($objs[$coid]->titleSize)); $t->addString($objs[$coid]->title); $i = $m->add($t); if ($in == 0) { $i->moveTo(5, 0); } } foreach ($el['text'] as $in => $val) { if (!empty($el['text'][$in]['data'])) { $t = new SWFTextField(); $t->setColor($defaultColor[0], $defaultColor[1], $defaultColor[2]); $t->align(SWFTEXTFIELD_ALIGN_LEFT); $t->setFont($f);
$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"); $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("Indoor"); $txt->setColor(255, 0, 0); $txt->moveTo($dist_x + 60, $dist_y); $txt->addString("Temp (F)"); $txt->setColor(0, 0, 0); $txt->moveTo($dist_x + 145, $dist_y); $txt->addString("and"); $txt->setColor(0, 190, 0); $txt->moveTo($dist_x + 185, $dist_y); $txt->addString("Humidity");
#!/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("1234567890"); $tf = new SWFTextField(); $tf->setFont($f); $tf->setHeight(20); $tf->setColor(0xff, 0x0, 0x0); $tf->addString("1234567890"); $m->add($t); $it = $m->add($tf); $it->moveTo(100, 120); $m->nextFrame(); /* end of frame 1 */ $m->save("test04.swf");
#!/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");
} $font_height = 0; if (!isset($context['flash_font_r']) || !($r = intval($context['flash_font_r']))) { $r = 0x11; } if (!isset($context['flash_font_g']) || !($g = intval($context['flash_font_g']))) { $g = 0x33; } if (!isset($context['flash_font_b']) || !($b = intval($context['flash_font_b']))) { $b = 0x33; } if (!isset($context['flash_font_height']) || !($height = intval($context['flash_font_height']))) { $height = 40; } 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();
/** * Returns boundings of text depending on the available font extension * * @param float $size Textsize * @param ezcGraphFontOptions $font Font * @param string $text Text * @return ezcGraphBoundings Boundings of text */ protected function getTextBoundings($size, ezcGraphFontOptions $font, $text) { $t = new SWFText(); $t->setFont(new SWFFont($font->path)); $t->setHeight($size); $boundings = new ezcGraphBoundings(0, 0, $t->getWidth($text), $size); return $boundings; }
#!/usr/bin/php -c. <?php $srcdir = $argv[1]; $mediadir = $srcdir . "/../Media"; $m = new SWFMovie(); ming_setscale(1.0); $f2 = new SWFFont($mediadir . "/font01.fdb"); $f3 = new SWFFont($mediadir . "/test.ttf"); /* SWF_DEFINETEXT2 */ $character1 = new SWFText(2); $character1->setFont($f2); $character1->setHeight(400); $character1->setColor(0x0, 0x0, 0x0, 0xff); $character1->addString("abc"); $character1->setFont($f3); $character1->setHeight(800); $character1->setColor(0xff, 0x0, 0x0, 0xff); $character1->addString("def"); $i1 = $m->add($character1); $i1->setDepth(1); $m->nextFrame(); /* end of frame 1 */ $m->save("test02.swf");
#!/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");
$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"); $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");