示例#1
0
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);
}
示例#2
0
function text($string)
{
    global $font;
    $t = new SWFText();
    $t->setFont($font);
    $t->setColor(255, 255, 255);
    $t->setHeight(20);
    $t->addString($string);
    return $t;
}
示例#3
0
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;
}
示例#4
0
 /**
  * Draw an awFileFont object on a Flash movie
  *
  * @param awGDDriver $driver The awMingDriver object containing the movie to draw upon
  * @param awText $text The awText object containing the string to draw
  * @param awPoint $point Where to draw the string from
  * @param float $width The width of the area containing the text
  */
 private function mingString(awMingDriver $driver, awText $text, awPoint $point, $width = NULL)
 {
     $font = $text->getFont();
     if ($font instanceof awFDBFont === FALSE and $font->getExtension() === NULL) {
         $font->setExtension('fdb');
     }
     list($red, $green, $blue, $alpha) = $driver->getColor($text->getColor());
     $fontPath = ARTICHOW_FONT . '/' . $font->name . '.' . $font->getExtension();
     $flashFont = new SWFFont($fontPath);
     $flashText = new SWFText();
     $flashText->setFont($flashFont);
     $flashText->setColor($red, $green, $blue, $alpha);
     // Multiply the font size by 1.33 to get the same size on screen as in GD (roughly)
     $flashText->setHeight($font->size * 1.33);
     $flashText->addString($text->getText());
     $item = $driver->movie->add($flashText);
     $item->rotateTo($text->getAngle());
     $box = awFileFontDriver::mingfdbbox($font->size, $text->getAngle(), $text->getText(), $flashText);
     $textHeight = -$box[5];
     $box = awFileFontDriver::mingfdbbox($font->size, 90, $text->getText(), $flashText);
     $textWidth = abs($box[6] - $box[2]);
     // Reposition the text so it's in the same position than with the GD driver.
     $item->moveTo($driver->x + $point->x + $textWidth * sin($text->getAngle() / 180 * M_PI), $driver->y + $point->y + $textHeight);
 }
示例#5
0
 /**
  * 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;
 }
示例#6
0
$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)");
$txt->setColor(0, 0, 0);
$txt->moveTo($dist_x + 285, $dist_y);
$txt->addString("vs. Time");
示例#7
0
文件: SWF.php 项目: roojs/pear
 /**
  * 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);
 }
示例#8
0
$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);
    for ($j = 0; $j <= 30; ++$j) {
        $i->scaleTo(sqrt(sqrt($j / 30)));
示例#9
0
文件: test05.php 项目: mgorny/libming
#!/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");
示例#10
0
文件: test03.php 项目: mgorny/libming
#!/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");
示例#11
0
文件: test01.php 项目: mgorny/libming
#!/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");
示例#12
0
$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);
$racket_player->moveTo(10, 215);
$racket_player->setName("racketPlayer");
$src = new SWFSprite();
示例#13
0
     $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);
             $t->setHeight((int) ($_GET['h'] / 5));
             $t->addString($el['text'][$in]['data']);
             $i = $m->add($t);
示例#14
0
文件: test01.php 项目: mgorny/libming
#!/usr/bin/php -c.

<?php 
$srcdir = $argv[1];
$mediadir = $srcdir . "/../../Media";
$m = new SWFMovie(9);
ming_setscale(1.0);
$f2 = new SWFFont($mediadir . "/font01.fdb");
/* SWF_DEFINETEXT */
$character1 = new SWFText(1);
$character1->setFont($f2);
$character1->setHeight(200);
$character1->setColor(0x0, 0x0, 0x0);
$character1->moveTo(200, 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_SYMBOLCLASS */
$m->assignSymbol($character1, "mytext");
/* SWF_END */
$m->save("test01.swf");
示例#15
0
文件: slashdot.php 项目: rair/yacs
 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();
     $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) {