Index: phpdoc/en/functions/ming.xml diff -u phpdoc/en/functions/ming.xml:1.22 phpdoc/en/functions/ming.xml:1.23 --- phpdoc/en/functions/ming.xml:1.22 Sun Sep 30 14:36:39 2001 +++ phpdoc/en/functions/ming.xml Wed Oct 17 20:20:45 2001 @@ -1,4257 +1 @@ - - - - Ming functions for Flash - Ming (flash) - - - &warn.experimental; - - Introduction - - Ming is an open-source (LGPL) library which allows you to create SWF - ("Flash") format movies. Ming supports almost all of Flash 4's features, - including: shapes, gradients, bitmaps (pngs and jpegs), morphs ("shape - tweens"), text, buttons, actions, sprites ("movie clips"), streaming mp3, - and color transforms--the only thing that's missing is sound events. - - - Ming is not an acronym. - - - Note that all values specifying length, distance, size, etc. are in "twips", - twenty units per pixel. That's pretty much arbitrary, though, since the player - scales the movie to whatever pixel size is specified in the embed/object tag, - or the entire frame if not embedded. - - - Ming offers a number of advantages over the existing PHP/libswf module. - You can use Ming anywhere you can compile the code, whereas libswf is - closed-source and only available for a few platforms, Windows not one of - them. Ming provides some insulation from the mundane details of the SWF - file format, wrapping the movie elements in PHP objects. Also, Ming is - still being maintained; if there's a feature that you want to see, just - let us know &email.ming;. - - - Ming was added in PHP 4.0.5. - - - - - Installation - - To use Ming with PHP, you first need to build and install the Ming - library. Source code and installation instructions are available at the - Ming home page : &url.ming; - along with examples, a small tutorial, and the latest news. - - - Download the ming archive. Unpack the archive. Go in the - Ming directory. make. make install. - - - This will build libming.so and install it - into /usr/lib/, and copy - ming.h into /usr/include/. - Edit the PREFIX= line in the - Makefile to change the installation directory. - - - built into php (unix) - - - mkdir <phpdir>/ext/ming - cp php_ext/* <phpdir>/ext/ming - cd <phpdir> - ./buildconf - ./configure --with-ming <other config options> - - Build and install php as usual, - Restart web server if necessary - - - - built into php (unix) - - download php_ming.so.gz. - uncompress it and copy it to your php modules directory. - (you can find your php module directory by running - php-config --extension-dir). - Now either just add extension=php_ming.so - to your php.ini file, or put - dl('php_ming.so'); at the head of all of your - Ming scripts. - - - - - How to use Ming - - Ming introduces 13 new object in PHP, all with matching methods and - attributes. To use them, you need to know about - objects. - - - - - swfmovie. - - - - - swfshape. - - - - - swfdisplayitem. - - - - - swfgradient. - - - - - - swfbitmap. - - - - - swffill. - - - - - swfmorph. - - - - - swftext. - - - - - swffont. - - - - - swftextfield. - - - - - swfsprite. - - - - - swfbutton. - - - - - swfaction. - - - - - - - - - - - SWFMovie - Creates a new movie object, representing an SWF version 4 movie. - - - Description - - - new swfmovie - - - - &warn.experimental.func; - - swfmovie creates a new movie object, - representing an SWF version 4 movie. - - - SWFMovie has the following methods : - swfmovie->output,swfmovie->save, - swfmovie->add, swfmovie->remove, - swfmovie->nextframe, swfmovie->setbackground, - swfmovie->setrate, swfmovie->setdimension, - swfmovie->setframes and swfmovie->streammp3. - - - See examples in : - swfdisplayitem->rotateto, swfshape->setline, - swfshape->addfill... Any example will use this object. - - - - - - - SWFMovie->output - Dumps your lovingly prepared movie out. - - - Description - - - void swfmovie->output - - - - &warn.experimental.func; - - swfmovie->output dumps your lovingly prepared movie out. - In PHP, preceding this with the command - -<?php -header('Content-type: application/x-shockwave-flash'); -?> - - convinces the browser to display this as a flash movie. - - - See also - swfmovie->save. - - - See examples in : - swfmovie->streammp3, - swfdisplayitem->rotateto, - swfaction... - Any example will use this method. - - - - - - - SWFMovie->save - Saves your movie in a file. - - - Description - - - void swfmovie->save - string filename - - - &warn.experimental.func; - - swfmovie->save saves your movie to the - file named filename. - - - See also - output. - - - - - - - SWFMovie->add - Adds any type of data to a movie. - - - Description - - - void swfmovie->add - ressource instance - - - &warn.experimental.func; - - swfmovie->add adds instance to - the current movie. instance is any type of data : - Shapes, text, fonts, etc. must all be add'ed to the movie to make this work. - - - For displayable types (shape, text, button, sprite), this returns an - SWFDisplayItem, a handle to the object in a display - list. Thus, you can add the same shape to a movie multiple - times and get separate handles back for each separate instance. - - - See also all other objects (adding this later), and - swfmovie->remove - - - See examples in : - swfdisplayitem->rotateto and - swfshape->addfill. - - - - - - - - SWFMovie->remove - Removes the object instance from the display list. - - - Description - - - void swfmovie->remove - resource instance - - - &warn.experimental.func; - - swfmovie->remove removes the object instance - instance from the display list. - - - See also - swfmovie->add. - - - - - - - SWFMovie->setbackground - Sets the background color. - - - Description - - - void swfmovie->setbackground - int red - int green - int blue - - - &warn.experimental.func; - - swfmovie->setbackground sets the background color. Why is - there no rgba version? Think about it. (Actually, that's not such a dumb - question after all- you might want to let the html background show through. - There's a way to do that, but it only works on IE4. Search the - &url.macromedia; site for - details.) - - - - - - - SWFMovie->setrate - Sets the animation's frame rate. - - - Description - - - void swfmovie->setrate - int rate - - - &warn.experimental.func; - - swfmovie->setrate sets the frame rate to - rate, in frame per seconds. - Animation will slow down if the player can't render frames fast enough- unless - there's a streaming sound, in which case display frames are sacrificed to - keep sound from skipping. - - - - - - - SWFMovie->setdimension - Sets the movie's width and height. - - - Description - - - void swfmovie->setdimension - int width - int height - - - &warn.experimental.func; - - swfmovie->setdimension sets the movie's width - to width and height to height. - - - - - - - SWFMovie->setframes - Sets the total number of frames in the animation. - - - Description - - - void swfmovie->setframes - string numberofframes - - - &warn.experimental.func; - - swfmovie->setframes sets the total number of frames - in the animation to numberofframes. - - - - - - - SWFMovie->nextframe - Moves to the next frame of the animation. - - - Description - - - void swfmovie->nextframe - - - - &warn.experimental.func; - - swfmovie->setframes moves to the next frame of - the animation. - - - - - - - - SWFMovie->streammp3 - Streams a MP3 file. - - - Description - - - void swfmovie->streammp3 - string mp3FileName - - - &warn.experimental.func; - - swfmovie->streammp3 streams the mp3 file - mp3FileName. Not very robust in dealing with - oddities (can skip over an initial ID3 tag, but that's about it). - Like SWFShape->addJpegFill, this isn't a stable function- we'll - probably need to make a separate SWFSound object to contain sound types. - - - Note that the movie isn't smart enough to put enough frames in to contain - the entire mp3 stream- you'll have to add (length of song * frames per second) - frames to get the entire stream in. - - - Yes, now you can use ming to put that rock and roll devil worship music - into your SWF files. Just don't tell the RIAA. - - <function>swfmovie->streammp3</function> example - -<?php - $m = new SWFMovie(); - $m->setRate(12.0); - $m->streamMp3("distortobass.mp3"); -// use your own MP3 - - // 11.85 seconds at 12.0 fps = 142 frames - $m->setFrames(142); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - - - SWFDisplayItem - Creates a new displayitem object. - - - Description - - - new swfdisplayitem - - - - &warn.experimental.func; - - swfdisplayitem creates a new swfdisplayitem object. - - - Here's where all the animation takes place. After you define a shape, - a text object, a sprite, or a button, you add it to the movie, then use - the returned handle to move, rotate, scale, or skew the thing. - - - SWFDisplayItem has the following methods : swfdisplayitem->move, - swfdisplayitem->moveto, swfdisplayitem->scaleto, - swfdisplayitem->scale, swfdisplayitem->rotate, - swfdisplayitem->rotateto, swfdisplayitem->skewxto, - swfdisplayitem->skewx, swfdisplayitem->skewyto - swfdisplayitem->skewyto, swfdisplayitem->setdepth - swfdisplayitem->remove, swfdisplayitem->setname - swfdisplayitem->setratio, swfdisplayitem->addcolor - and swfdisplayitem->multcolor. - - - - - - - SWFDisplayItem->moveTo - Moves object in global coordinates. - - - Description - - - void swfdisplayitem->moveto - int x - int y - - - &warn.experimental.func; - - swfdisplayitem->moveto moves the current object to - (x,y) in global coordinates. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->move. - - - - - - - SWFDisplayItem->move - Moves object in relative coordinates. - - - Description - - - void swfdisplayitem->move - int dx - int dy - - - &warn.experimental.func; - - swfdisplayitem->move moves the current object by - (dx,dy) from its - current position. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->moveto. - - - - - - - SWFDisplayItem->scaleTo - Scales the object in global coordinates. - - - Description - - - void swfdisplayitem->scaleto - int x - int y - - - &warn.experimental.func; - - swfdisplayitem->scaleto scales the current object to - (x,y) in global coordinates. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->scale. - - - - - - - SWFDisplayItem->scale - Scales the object in relative coordinates. - - - Description - - - void swfdisplayitem->scale - int dx - int dy - - - &warn.experimental.func; - - swfdisplayitem->scale scales the current object by - (dx,dy) from its - current size. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->scaleto. - - - - - - - SWFDisplayItem->rotateTo - Rotates the object in global coordinates. - - - Description - - - void swfdisplayitem->rotateto - float degrees - - - &warn.experimental.func; - - swfdisplayitem->rotateto set the current object - rotation to degrees degrees in global coordinates. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - This example bring three rotating string from the background to the - foreground. Pretty nice. - - <function>swfdisplayitem->rotateto</function> example - -<?php - $thetext = "ming!"; - - $f = new SWFFont("Bauhaus 93.fdb"); - - $m = new SWFMovie(); - $m->setRate(24.0); - $m->setDimension(2400, 1600); - $m->setBackground(0xff, 0xff, 0xff); - - // functions with huge numbers of arbitrary - // arguments are always a good idea! Really! - - 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(960); - $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2); - $t->addString($string); - - // we can add properties just like a normal php var, - // as long as the names aren't already used. - // e.g., we can't set $i->scale, because that's a function - - $i = $m->add($t); - $i->x = $x; - $i->y = $y; - $i->rot = $rot; - $i->s = $scale; - $i->rotateTo($rot); - $i->scale($scale, $scale); - - // but the changes are local to the function, so we have to - // return the changed object. kinda weird.. - - return $i; - } - - function step($i) - { - $oldrot = $i->rot; - $i->rot = 19*$i->rot/20; - $i->x = (19*$i->x + 1200)/20; - $i->y = (19*$i->y + 800)/20; - $i->s = (19*$i->s + 1.0)/20; - - $i->rotateTo($i->rot); - $i->scaleTo($i->s, $i->s); - $i->moveTo($i->x, $i->y); - - return $i; - } - - // see? it sure paid off in legibility: - - $i1 = text(0xff, 0x33, 0x33, 0xff, 900, 1200, 800, 0.03, $thetext); - $i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 1200, 800, 0.04, $thetext); - $i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 1200, 800, 0.001, $thetext); - - for($i=1; $i<=100; ++$i) - { - $i1 = step($i1); - $i2 = step($i2); - $i3 = step($i3); - - $m->nextFrame(); - } - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - See also - swfdisplayitem->rotate. - - - - - - - SWFDisplayItem->Rotate - Rotates in relative coordinates. - - - Description - - - void swfdisplayitem->rotate - float ddegrees - - - &warn.experimental.func; - - swfdisplayitem->rotate rotates the current object - by ddegrees degrees from its current rotation. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->rotateto. - - - - - - - SWFDisplayItem->skewXTo - Sets the X-skew. - - - Description - - - void swfdisplayitem->skewxto - float degrees - - - &warn.experimental.func; - - swfdisplayitem->skewxto sets the - x-skew to degrees. For degrees - is 1.0, it means a 45-degree forward slant. More is more forward, - less is more backward. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->skewx, - swfdisplayitem->skewy and - swfdisplayitem->skewyto. - - - - - - - SWFDisplayItem->skewX - Sets the X-skew. - - - Description - - - void swfdisplayitem->skewx - float ddegrees - - - &warn.experimental.func; - - swfdisplayitem->skewx adds ddegrees - to current x-skew. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->skewx, - swfdisplayitem->skewy and - swfdisplayitem->skewyto. - - - - - - - SWFDisplayItem->skewYTo - Sets the Y-skew. - - - Description - - - void swfdisplayitem->skewyto - float degrees - - - &warn.experimental.func; - - swfdisplayitem->skewyto sets the - y-skew to degrees. For degrees - is 1.0, it means a 45-degree forward slant. More is more upward, - less is more downward. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->skewy, - swfdisplayitem->skewx and - swfdisplayitem->skewxto. - - - - - - - SWFDisplayItem->skewY - Sets the Y-skew. - - - Description - - - void swfdisplayitem->skewy - float ddegrees - - - &warn.experimental.func; - - swfdisplayitem->skewy adds ddegrees - to current y-skew. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfdisplayitem->skewyto, - swfdisplayitem->skewx and - swfdisplayitem->skewxto. - - - - - - - SWFDisplayItem->setDepth - Sets z-order - - - Description - - - void swfdisplayitem->setdepth - float depth - - - &warn.experimental.func; - - swfdisplayitem->rotate sets the object's - z-order to depth. Depth defaults to the - order in which instances are created (by add'ing a shape/text to - a movie)- newer ones are on top of older ones. If two objects are - given the same depth, only the later-defined one can be moved. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - - - - - SWFDisplayItem->remove - Removes the object from the movie - - - Description - - - void swfdisplayitem->remove - - - - &warn.experimental.func; - - swfdisplayitem->remove removes this object from - the movie's display list. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - See also - swfmovie->add. - - - - - - - SWFDisplayItem->setName - Sets the object's name - - - Description - - - void swfdisplayitem->setname - string name - - - &warn.experimental.func; - - swfdisplayitem->setname sets the object's name to - name, for targetting with action script. - Only useful on sprites. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - - - - - SWFDisplayItem->setRatio - Sets the object's ratio. - - - Description - - - void swfdisplayitem->setratio - float ratio - - - &warn.experimental.func; - - swfdisplayitem->setratio sets the object's ratio - to ratio. Obviously only useful for morphs. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - This simple example will morph nicely three concentric circles. - - <function>swfdisplayitem->setname</function> example - -<?php - - $p = new SWFMorph(); - - $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(0.16, 0xff, 0xff, 0xff); - $g->addEntry(0.32, 0, 0, 0); - $g->addEntry(0.48, 0xff, 0xff, 0xff); - $g->addEntry(0.64, 0, 0, 0); - $g->addEntry(0.80, 0xff, 0xff, 0xff); - $g->addEntry(1.00, 0, 0, 0); - - $s = $p->getShape1(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.05); - $s->setLeftFill($f); - $s->movePenTo(-160, -120); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); - - $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(0.16, 0xff, 0, 0); - $g->addEntry(0.32, 0, 0, 0); - $g->addEntry(0.48, 0, 0xff, 0); - $g->addEntry(0.64, 0, 0, 0); - $g->addEntry(0.80, 0, 0, 0xff); - $g->addEntry(1.00, 0, 0, 0); - - $s = $p->getShape2(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.05); - $f->skewXTo(1.0); - $s->setLeftFill($f); - $s->movePenTo(-160, -120); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); - - $m = new SWFMovie(); - $m->setDimension(320, 240); - $i = $m->add($p); - $i->moveTo(160, 120); - - for($n=0; $n<=1.001; $n+=0.01) - { - $i->setRatio($n); - $m->nextFrame(); - } - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFDisplayItem->addColor - Adds the given color to this item's color transform. - - - Description - - - void swfdisplayitem->addcolor - int red - int green - int blue - int a - - - &warn.experimental.func; - - swfdisplayitem->addcolor adds the color to - this item's color transform. The color is given in its RGB form. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - - - - - SWFDisplayItem->multColor - Multiplies the item's color transform. - - - Description - - - void swfdisplayitem->multcolor - int red - int green - int blue - int a - - - &warn.experimental.func; - - swfdisplayitem->multcolor multiplies the item's - color transform by the given values. - - - The object may be a swfshape, a - swfbutton, a swftext or a - swfsprite object. It must have been added using - the swfmovie->add. - - - This simple example will modify your picture's atmospher - to Halloween (use a landscape or bright picture). - - <function>swfdisplayitem->multcolor</function> example - -<?php - - $b = new SWFBitmap("backyard.jpg"); - // note use your own picture :-) - $s = new SWFShape(); - $s->setRightFill($s->addFill($b)); - $s->drawLine($b->getWidth(), 0); - $s->drawLine(0, $b->getHeight()); - $s->drawLine(-$b->getWidth(), 0); - $s->drawLine(0, -$b->getHeight()); - - $m = new SWFMovie(); - $m->setDimension($b->getWidth(), $b->getHeight()); - - $i = $m->add($s); - - for($n=0; $n<=20; ++$n) - { - $i->multColor(1.0-$n/10, 1.0, 1.0); - $i->addColor(0xff*$n/20, 0, 0); - $m->nextFrame(); - } - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - - - SWFShape - Creates a new shape object. - - - Description - - - new swfshape - - - - &warn.experimental.func; - - swfshape creates a new shape object. - - - SWFShape has the following methods : swfshape->setline, - swfshape->addfill, swfshape->setleftfill, - swfshape->setrightfill, swfshape->movepento, - swfshape->movepen, swfshape->drawlineto, - swfshape->drawline, swfshape->drawcurveto - and swfshape->drawcurve. - - - This simple example will draw a big red elliptic quadrant. - - <function>swfshape</function> example - -<?php - $s = new SWFShape(); - $s->setLine(40, 0x7f, 0, 0); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(200, 200); - $s->drawLineTo(6200, 200); - $s->drawLineTo(6200, 4600); - $s->drawCurveTo(200, 4600, 200, 200); - - $m = new SWFMovie(); - $m->setDimension(6400, 4800); - $m->setRate(12.0); - $m->add($s); - $m->nextFrame(); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFShape->setLine - Sets the shape's line style. - - - Description - - - void swfshape->setline - int width - int red - int green - int blue - int a - - - &warn.experimental.func; - - swfshape->setline sets the shape's line style. - width is the line's width. If width - is 0, the line's style is removed (then, all other arguments are ignored). - If width > 0, then line's color is set to - red, green, blue. - Last parameter a is optional. - - - swfshape->setline accepts 1, 4 or 5 arguments - (not 3 or 2). - - - You must declare all line styles before you use them (see example). - - - This simple example will draw a big "!#%*@", in funny colors and - gracious style. - - <function>swfshape->setline</function> example - -<?php - $s = new SWFShape(); - $f1 = $s->addFill(0xff, 0, 0); - $f2 = $s->addFill(0xff, 0x7f, 0); - $f3 = $s->addFill(0xff, 0xff, 0); - $f4 = $s->addFill(0, 0xff, 0); - $f5 = $s->addFill(0, 0, 0xff); - - // bug: have to declare all line styles before you use them - $s->setLine(40, 0x7f, 0, 0); - $s->setLine(40, 0x7f, 0x3f, 0); - $s->setLine(40, 0x7f, 0x7f, 0); - $s->setLine(40, 0, 0x7f, 0); - $s->setLine(40, 0, 0, 0x7f); - - $f = new SWFFont('Techno.fdb'); - - $s->setRightFill($f1); - $s->setLine(40, 0x7f, 0, 0); - $s->drawGlyph($f, '!'); - $s->movePen($f->getWidth('!'), 0); - - $s->setRightFill($f2); - $s->setLine(40, 0x7f, 0x3f, 0); - $s->drawGlyph($f, '#'); - $s->movePen($f->getWidth('#'), 0); - - $s->setRightFill($f3); - $s->setLine(40, 0x7f, 0x7f, 0); - $s->drawGlyph($f, '%'); - $s->movePen($f->getWidth('%'), 0); - - $s->setRightFill($f4); - $s->setLine(40, 0, 0x7f, 0); - $s->drawGlyph($f, '*'); - $s->movePen($f->getWidth('*'), 0); - - $s->setRightFill($f5); - $s->setLine(40, 0, 0, 0x7f); - $s->drawGlyph($f, '@'); - - $m = new SWFMovie(); - $m->setDimension(3000,2000); - $m->setRate(12.0); - $i = $m->add($s); - $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFShape->addFill - Adds a solid fill to the shape. - - - Description - - - void swfshape->addfill - int red - int green - int blue - int a - - - &warn.experimental.func; - - - void swfshape->addfill - SWFbitmap bitmap - int flags - - - &warn.experimental.func; - - - void swfshape->addfill - SWFGradient gradient - int flags - - - &warn.experimental.func; - - swfshape->addfill adds a solid fill to the shape's list - of fill styles. swfshape->addfill accepts three different - types of arguments. - - - red, green, blue - is a color (RGB mode). Last parameter a is optional. - - - The bitmap argument is an swfbitmap object. - The flags argument can be one - of the following values : SWFFILL_CLIPPED_BITMAP or SWFFILL_TILED_BITMAP. - Default is SWFFILL_TILED_BITMAP. I think. - - - The gradient argument is an swfgradient - object. The flags argument can be one of the following values : - SWFFILL_RADIAL_GRADIENT or SWFFILL_LINEAR_GRADIENT. Default is - SWFFILL_LINEAR_GRADIENT. I'm sure about this one. Really. - - - swfshape->addfill returns an swffill - object for use with the swfshape->setleftfill - and swfshape->setrightfill functions - described below. - - - See also - swfshape->setleftfill and - swfshape->setrightfill. - - - This simple example will draw a frame on a bitmap. Ah, here's another buglet in - the flash player- it doesn't seem to care about the second shape's bitmap's - transformation in a morph. According to spec, the bitmap should stretch - along with the shape in this example.. - - <function>swfshape->addfill</function> example - -<?php - - $p = new SWFMorph(); - - $b = new SWFBitmap("alphafill.jpg"); - // use your own bitmap - $width = $b->getWidth(); - $height = $b->getHeight(); - - $s = $p->getShape1(); - $f = $s->addFill($b, SWFFILL_TILED_BITMAP); - $f->moveTo(-$width/2, -$height/4); - $f->scaleTo(1.0, 0.5); - $s->setLeftFill($f); - $s->movePenTo(-$width/2, -$height/4); - $s->drawLine($width, 0); - $s->drawLine(0, $height/2); - $s->drawLine(-$width, 0); - $s->drawLine(0, -$height/2); - - $s = $p->getShape2(); - $f = $s->addFill($b, SWFFILL_TILED_BITMAP); - - // these two have no effect! - $f->moveTo(-$width/4, -$height/2); - $f->scaleTo(0.5, 1.0); - - $s->setLeftFill($f); - $s->movePenTo(-$width/4, -$height/2); - $s->drawLine($width/2, 0); - $s->drawLine(0, $height); - $s->drawLine(-$width/2, 0); - $s->drawLine(0, -$height); - - $m = new SWFMovie(); - $m->setDimension($width, $height); - $i = $m->add($p); - $i->moveTo($width/2, $height/2); - - for($n=0; $n<1.001; $n+=0.03) - { - $i->setRatio($n); - $m->nextFrame(); - } - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFShape->setLeftFill - Sets left rasterizing color. - - - Description - - - void swfshape->setleftfill - swfgradient fill - - - &warn.experimental.func; - - - void swfshape->setleftfill - int red - int green - int blue - int a - - - &warn.experimental.func; - - What this nonsense is about is, every edge segment borders at most two fills. - When rasterizing the object, it's pretty handy to know what those fills are - ahead of time, so the swf format requires these to be specified. - - - swfshape->setleftfill sets the fill on the left side of - the edge- that is, on the interior if you're defining the outline of the shape in a counter-clockwise - fashion. The fill object is an SWFFill object returned from one of the addFill - functions above. - - - This seems to be reversed when you're defining a shape in a morph, though. - If your browser crashes, just try setting the fill on the other side. - - - Shortcut for swfshape->setleftfill($s->addfill($r, $g, $b [, $a]));. - - - See also - swfshape->setrightfill. - - - - - - - SWFShape->setRightFill - Sets right rasterizing color. - - - Description - - - void swfshape->setrightfill - swfgradient fill - - - &warn.experimental.func; - - - void swfshape->setrightfill - int red - int green - int blue - int a - - - &warn.experimental.func; - - See also - swfshape->setleftfill. - - - Shortcut for swfshape->setrightfill($s->addfill($r, $g, $b [, $a]));. - - - - - - - SWFShape->movePenTo - Moves the shape's pen. - - - Description - - - void swfshape->movepento - int x - int y - - - &warn.experimental.func; - - swfshape->setrightfill move the shape's pen to - (x,y) in the shape's - coordinate space. - - - See also - swfshape->movepen, - swfshape->drawcurveto, - swfshape->drawlineto and - swfshape->drawline. - - - - - - - SWFShape->movePen - Moves the shape's pen (relative). - - - Description - - - void swfshape->movepen - int dx - int dy - - - &warn.experimental.func; - - swfshape->setrightfill move the shape's pen from - coordinates (current x,current y) to (current x + dx, - current y + dy) in the shape's coordinate space. - - - See also - swfshape->movepento, - swfshape->drawcurveto, - swfshape->drawlineto and - swfshape->drawline. - - - - - - - SWFShape->drawLineTo - Draws a line. - - - Description - - - void swfshape->drawlineto - int x - int y - - - &warn.experimental.func; - - swfshape->setrightfill draws a line (using the - current line style, set by swfshape->setline) from the current - pen position to point (x,y) - in the shape's coordinate space. - - - See also - swfshape->movepento, - swfshape->drawcurveto, - swfshape->movepen and - swfshape->drawline. - - - - - - - SWFShape->drawLine - Draws a line (relative). - - - Description - - - void swfshape->drawline - int dx - int dy - - - &warn.experimental.func; - - swfshape->setrightfill draws a line (using the current line style - set by swfshape->setline) from the current pen position to - displacement (dx,dy). - - - See also - swfshape->movepento, - swfshape->drawcurveto, - swfshape->movepen and - swfshape->drawlineto. - - - - - - - SWFShape->drawCurveTo - Draws a curve. - - - Description - - - void swfshape->drawcurveto - int controlx - int controly - int anchorx - int anchory - - - &warn.experimental.func; - - swfshape->drawcurveto draws a quadratic curve - (using the current line style, set by swfshape->setline) - from the current pen position to - (anchorx,anchory) - using (controlx,controly) - as a control point. That is, head towards the control point, - then smoothly turn to the anchor point. - - - See also - swfshape->drawlineto, - swfshape->drawline, - swfshape->movepento and - swfshape->movepen. - - - - - - - SWFShape->drawCurve - Draws a curve (relative). - - - Description - - - void swfshape->drawcurve - int controldx - int controldy - int anchordx - int anchordy - - - &warn.experimental.func; - - swfshape->drawcurve draws a quadratic curve - (using the current line style,set by swfshape->setline) - from the current pen position to the relative position - (anchorx,anchory) - using relative control point - (controlx,controly). - That is, head towards the control point, then smoothly turn to the - anchor point. - - - See also - swfshape->drawlineto, - swfshape->drawline, - swfshape->movepento and - swfshape->movepen. - - - - - - - - - SWFGradient - Creates a gradient object - - - Description - - - new swfgradient - - - - &warn.experimental.func; - - swfgradient creates a new SWFGradient object. - - - After you've added the entries to your gradient, you can use the gradient - in a shape fill with the swfshape->addfill method. - - - SWFGradient has the following methods : swfgradient->addentry. - - - This simple example will draw a big black-to-white gradient as background, - and a redish disc in its center. - - <function>swfgradient</function> example - -<?php - - $m = new SWFMovie(); - $m->setDimension(320, 240); - - $s = new SWFShape(); - - // first gradient- black to white - $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(1.0, 0xff, 0xff, 0xff); - - $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); - $f->scaleTo(0.01); - $f->moveTo(160, 120); - $s->setRightFill($f); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); - - $m->add($s); - - $s = new SWFShape(); - - // second gradient- radial gradient from red to transparent - $g = new SWFGradient(); - $g->addEntry(0.0, 0xff, 0, 0, 0xff); - $g->addEntry(1.0, 0xff, 0, 0, 0); - - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.005); - $f->moveTo(160, 120); - $s->setRightFill($f); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); - - $m->add($s); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFGradient->addEntry - Adds an entry to the gradient list. - - - Description - - - void swfgradient->addentry - float ratio - int red - int green - int blue - int a - - - &warn.experimental.func; - - swfgradient->addentry adds an entry to the gradient list. - ratio is a number between 0 and 1 indicating where in - the gradient this color appears. Thou shalt add entries in order of increasing ratio. - - - red, green, blue - is a color (RGB mode). Last parameter a is optional. - - - - - - - - - SWFBitmap - Loads Bitmap object - - - Description - - - new swfbitmap - string filename - int alphafilename - - - &warn.experimental.func; - - swfbitmap creates a new SWFBitmap object from - the Jpeg or DBL file named filename. - alphafilename indicates a MSK file to - be used as an alpha mask for a Jpeg image. - - - - We can only deal with baseline (frame 0) jpegs, no baseline optimized or - progressive scan jpegs! - - - - SWFBitmap has the following methods : swfbitmap->getwidth - and swfbitmap->getheight. - - - You can't import png images directly, though- have to use the png2dbl - utility to make a dbl ("define bits lossless") file from the png. - The reason for this is that I don't want a dependency on the png library - in ming- autoconf should solve this, but that's not set up yet. - - Import PNG files - -<?php - $s = new SWFShape(); - $f = $s->addFill(new SWFBitmap("png.dbl")); - $s->setRightFill($f); - - $s->drawLine(32, 0); - $s->drawLine(0, 32); - $s->drawLine(-32, 0); - $s->drawLine(0, -32); - - $m = new SWFMovie(); - $m->setDimension(32, 32); - $m->add($s); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - And you can put an alpha mask on a jpeg fill. - - <function>swfbitmap</function> example - -<?php - - $s = new SWFShape(); - - // .msk file generated with "gif2mask" utility - $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk")); - $s->setRightFill($f); - - $s->drawLine(640, 0); - $s->drawLine(0, 480); - $s->drawLine(-640, 0); - $s->drawLine(0, -480); - - $c = new SWFShape(); - $c->setRightFill($c->addFill(0x99, 0x99, 0x99)); - $c->drawLine(40, 0); - $c->drawLine(0, 40); - $c->drawLine(-40, 0); - $c->drawLine(0, -40); - - $m = new SWFMovie(); - $m->setDimension(640, 480); - $m->setBackground(0xcc, 0xcc, 0xcc); - - // draw checkerboard background - for($y=0; $y<480; $y+=40) - { - for($x=0; $x<640; $x+=80) - { - $i = $m->add($c); - $i->moveTo($x, $y); - } - - $y+=40; - - for($x=40; $x<640; $x+=80) - { - $i = $m->add($c); - $i->moveTo($x, $y); - } - } - - $m->add($s); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFBitmap->getWidth - Returns the bitmap's width. - - - Description - - - int swfbitmap->getwidth - - - - &warn.experimental.func; - - swfbitmap->getwidth returns the bitmap's width in pixels. - - - See also - swfbitmap->getheight. - - - - - - - SWFBitmap->getHeight - Returns the bitmap's height. - - - Description - - - int swfbitmap->getheight - - - - &warn.experimental.func; - - swfbitmap->getheight returns the bitmap's height in pixels. - - - See also - swfbitmap->getwidth. - - - - - - - - - SWFFill - Loads SWFFill object - - - Description - - The swffill object allows you to transform - (scale, skew, rotate) bitmap and gradient fills. swffill - objects are created by the swfshape->addfill methods. - - - SWFFill has the following methods : swffill->moveto - and swffill->scaleto, swffill->rotateto, - swffill->skewxto and swffill->skewyto. - - - - - - - SWFFill->moveTo - Moves fill origin - - - Description - - - void swffill->moveto - int x - int y - - - &warn.experimental.func; - - swffill->moveto moves fill's origin to - (x,y) in global coordinates. - - - - - - - SWFFill->scaleTo - Sets fill's scale - - - Description - - - void swffill->scaleto - int x - int y - - - &warn.experimental.func; - - swffill->scaleto sets fill's scale to - x in the x-direction, - y in the y-direction. - - - - - - - SWFFill->rotateTo - Sets fill's rotation - - - Description - - - void swffill->rotateto - float degrees - - - &warn.experimental.func; - - swffill->rotateto sets fill's rotation to - degrees degrees. - - - - - - - SWFFill->skewXTo - Sets fill x-skew - - - Description - - - void swffill->skewxto - float x - - - &warn.experimental.func; - - swffill->skewxto sets fill x-skew to x. - For x is 1.0, it is a is a 45-degree - forward slant. More is more forward, less is more backward. - - - - - - - SWFFill->skewYTo - Sets fill y-skew - - - Description - - - void swffill->skewyto - float y - - - &warn.experimental.func; - - swffill->skewyto sets fill y-skew to y. - For y is 1.0, it is a is a 45-degree - upward slant. More is more upward, less is more downward. - - - - - - - - - SWFMorph - Creates a new SWFMorph object. - - - Description - - - new swfmorph - - - - &warn.experimental.func; - - swfmorph creates a new SWFMorph object. - - - Also called a "shape tween". This thing lets you make those tacky - twisting things that make your computer choke. Oh, joy! - - - The methods here are sort of weird. It would make more sense to just - have newSWFMorph(shape1, shape2);, but as things are now, shape2 needs - to know that it's the second part of a morph. (This, because it starts - writing its output as soon as it gets drawing commands- if it kept its - own description of its shapes and wrote on completion this and some - other things would be much easier.) - - - SWFMorph has the following methods : swfmorph->getshape1 - and swfmorph->getshape1. - - - This simple example will morph a big red square into a smaller - blue black-bordered square. - - <function>swfmorph</function> example - -<?php - $p = new SWFMorph(); - - $s = $p->getShape1(); - $s->setLine(0,0,0,0); - - /* Note that this is backwards from normal shapes (left instead of right). - I have no idea why, but this seems to work.. */ - - $s->setLeftFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(-1000,-1000); - $s->drawLine(2000,0); - $s->drawLine(0,2000); - $s->drawLine(-2000,0); - $s->drawLine(0,-2000); - - $s = $p->getShape2(); - $s->setLine(60,0,0,0); - $s->setLeftFill($s->addFill(0, 0, 0xff)); - $s->movePenTo(0,-1000); - $s->drawLine(1000,1000); - $s->drawLine(-1000,1000); - $s->drawLine(-1000,-1000); - $s->drawLine(1000,-1000); - - $m = new SWFMovie(); - $m->setDimension(3000,2000); - $m->setBackground(0xff, 0xff, 0xff); - - $i = $m->add($p); - $i->moveTo(1500,1000); - - for($r=0.0; $r<=1.0; $r+=0.1) - { - $i->setRatio($r); - $m->nextFrame(); - } - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFMorph->getshape1 - Gets a handle to the starting shape - - - Description - - - mixed swfmorph->getshape1 - - - - &warn.experimental.func; - - swfmorph->getshape1 gets a handle to the morph's - starting shape. swfmorph->getshape1 returns an - swfshape object. - - - - - - - SWFMorph->getshape2 - Gets a handle to the ending shape - - - Description - - - mixed swfmorph->getshape2 - - - - &warn.experimental.func; - - swfmorph->getshape2 gets a handle to the morph's - ending shape. swfmorph->getshape2 returns an - swfshape object. - - - - - - - - - SWFText - Creates a new SWFText object. - - - Description - - - new swftext - - - - &warn.experimental.func; - - swftext creates a new SWFText object, - fresh for manipulating. - - - SWFText has the following methods : swftext->setfont, - swftext->setheight, swftext->setspacing, - swftext->setcolor, swftext->moveto, - swftext->addstring and swftext->getwidth. - - - This simple example will draw a big yellow "PHP generates Flash with Ming" - text, on white background. - - <function>swftext</function> example - -<?php - $f = new SWFFont("Techno.fdb"); - $t = new SWFText(); - $t->setFont($f); - $t->moveTo(200, 2400); - $t->setColor(0xff, 0xff, 0); - $t->setHeight(1200); - $t->addString("PHP generates Flash with Ming!!"); - - $m = new SWFMovie(); - $m->setDimension(5400, 3600); - - $m->add($t); - - header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> - - - - - - - - - SWFText->setFont - Sets the current font - - - Description - - - void swftext->setfont - string font - - - &warn.experimental.func; - - swftext->setfont sets the current font to - font. - - - - - - - SWFText->setHeight - Sets the current font height - - - Description - - - void swftext->setheight - int height - - - &warn.experimental.func; - - swftext->setheight sets the current font height to - height. Default is 240. - - - - - - - SWFText->setSpacing - Sets the current font spacing - - - Description - - - void swftext->setspacing - float spacing - - - &warn.experimental.func; - - swftext->setspacing sets the current font spacing to - spacingspacing. Default is 1.0. - 0 is all of the letters written at the same point. This doesn't really work - that well because it inflates the advance across the letter, doesn't add - the same amount of spacing between the letters. I should try and explain - that better, prolly. Or just fix the damn thing to do constant spacing. - This was really just a way to figure out how letter advances work, - anyway.. So nyah. - - - - - - - SWFText->setColor - Sets the current font color - - - Description - - - void swftext->setcolor - int red - int green - int blue - int a - - - &warn.experimental.func; - - swftext->setspacing changes the current text color. - Default is black. I think. Color is represented using the RGB system. - - - - - - - SWFText->moveTo - Moves the pen - - - Description - - - void swftext->moveto - int x - int y - - - &warn.experimental.func; - - swftext->moveto moves the pen (or cursor, if - that makes more sense) to (x,y) - in text object's coordinate space. If either is zero, though, value - in that dimension stays the same. Annoying, should be fixed. - - - - - - - SWFText->addString - Draws a string - - - Description - - - void swftext->addstring - string string - - - &warn.experimental.func; - - swftext->addstring draws the string string - at the current pen (cursor) location. Pen is at the baseline of the text; - i.e., ascending text is in the -y direction. - - - - - - - SWFText->getWidth - Computes string's width - - - Description - - - void swftext->addstring - string string - - - &warn.experimental.func; - - swftext->addstring returns the rendered width of the - string string at the text object's current font, - scale, and spacing settings. - - - - - - - - - SWFFont - Loads a font definition - - - Description - - - new swffont - string filename - - - &warn.experimental.func; - - If filename is the name of an FDB file - (i.e., it ends in ".fdb"), load the font definition found in said - file. Otherwise, create a browser-defined font reference. - - - FDB ("font definition block") is a very simple wrapper for the SWF DefineFont2 - block which contains a full description of a font. One may create FDB files from - SWT Generator template files with the included makefdb utility- look in the - util directory off the main ming distribution directory. - - - Browser-defined fonts don't contain any information about the font other - than its name. It is assumed that the font definition will be provided by - the movie player. The fonts _serif, _sans, and _typewriter should always - be available. For example: - -<?php -$f = newSWFFont("_sans"); -?> - - will give you the standard sans-serif font, probably the same as what you'd get - with <font name="sans-serif"> in HTML. - - - swffont returns a reference to the font - definition, for use in the SWFText->setFont - and the SWFTextField->setFont methods. - - - SWFFont has the following methods : swffont->getwidth. - - - - - - - swffont->getwidth - Returns the string's width - - - Description - - - int swffont->getwidth - string string - - - &warn.experimental.func; - - swffont->getwidth returns the string - string's width, using font's default scaling. - You'll probably want to use the SWFText version of this method which - uses the text object's scale. - - - - - - - - - SWFTextField - Creates a text field object - - - Description - - - new swftextfield - int flags - - - &warn.experimental.func; - - swftextfield creates a new text field object. - Text Fields are less flexible than swftext objects- - they can't be rotated, scaled non-proportionally, or skewed, but they can - be used as form entries, and they can use browser-defined fonts. - - - The optional flags change the text field's behavior. It has the following - possibles values : - - - - SWFTEXTFIELD_NOEDIT indicates that the field shouldn't be user-editable - - - - - SWFTEXTFIELD_PASSWORD obscures the data entry - - - - - SWFTEXTFIELD_DRAWBOX draws the outline of the textfield - - - - - SWFTEXTFIELD_MULTILINE allows multiple lines - - - - - SWFTEXTFIELD_WORDWRAP allows text to wrap - - - - - SWFTEXTFIELD_NOSELECT makes the field non-selectable - - - - Flags are combined with the bitwise - OR operation. For example, - -<?php -$t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT); -?> - - creates a totally useless non-editable password field. - - - SWFTextField has the following methods : swftextfield->setfont, - swftextfield->setbounds, swftextfield->align, - swftextfield->setheight, swftextfield->setleftmargin, - swftextfield->setrightmargin, swftextfield->setmargins, - swftextfield->setindentation, swftextfield->setlinespacing, - swftextfield->setcolor, swftextfield->setname and - swftextfield->addstring. - - - - - - - SWFTextField->setFont - Sets the text field font - - - Description - - - void swftextfield->setfont - string font - - - &warn.experimental.func; - - swftextfield->setfont sets the text field font to - the [browser-defined?] font font. - - - - - - - SWFTextField->setbounds - Sets the text field width and height - - - Description - - - void swftextfield->setbounds - int width - int height - - - &warn.experimental.func; - - swftextfield->setbounds sets the text field width - to width and height to height. - If you don't set the bounds yourself, Ming makes a poor guess at what - the bounds are. - - - - - - - SWFTextField->align - Sets the text field alignment - - - Description - - - void swftextfield->align - int alignement - - - &warn.experimental.func; - - swftextfield->align sets the text field alignment - to alignement. Valid values for - alignement are : SWFTEXTFIELD_ALIGN_LEFT, - SWFTEXTFIELD_ALIGN_RIGHT, SWFTEXTFIELD_ALIGN_CENTER and - SWFTEXTFIELD_ALIGN_JUSTIFY. - - - - - - - SWFTextField->setHeight - Sets the font height of this text field font. - - - Description - - - void swftextfield->setheight - int height - - - &warn.experimental.func; - - swftextfield->setheight sets the font height of this text field - font to the given height height. Default is 240. - - - - - - - SWFTextField->setLeftMargin - Sets the left margin width of the text field. - - - Description - - - void swftextfield->setleftmargin - int width - - - &warn.experimental.func; - - swftextfield->setleftmargin sets the left margin width - of the text field to width. Default is 0. - - - - - - - SWFTextField->setrightMargin - Sets the right margin width of the text field. - - - Description - - - void swftextfield->setrightmargin - int width - - - &warn.experimental.func; - - swftextfield->setrightmargin sets the right margin width - of the text field to width. Default is 0. - - - - - - - SWFTextField->setMargins - Sets the margins width of the text field. - - - Description - - -