Differences between revisions 3 and 4
Revision 3 as of 2008-09-01 10:19:10
Size: 1424
Editor: klaus
Comment:
Revision 4 as of 2008-09-01 16:20:38
Size: 2337
Editor: klaus
Comment:
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
=== MovieClip DropShadow Example ===
{{{
#include <ming.h>
#include <stdlib.h>
int main()
{
 SWFMovie m;
 SWFShape shape;
 SWFMovieClip mc;
 SWFDisplayItem item;
 SWFBlur blur;
 SWFFilter f;
 SWFShadow shadow;
 SWFColor c;

 Ming_init();
 m = newSWFMovieWithVersion(7);
 if(m == NULL)
  return EXIT_FAILURE;
 
 shape = newSWFShape();

 SWFShape_setLine(shape, 4, 0, 0, 0, 255);
 SWFShape_movePenTo(shape, 50, 50);
 SWFShape_drawLineTo(shape, 0, 10);
 
 blur = newSWFBlur(5,5,1);
 shadow = newSWFShadow(0.79, 2, 1);
 c.red = 0xcf;
 c.green = 0xcf;
 c.blue = 0xcf;
 c.alpha = 0xff;

 f = newDropShadowFilter(c, blur, shadow, FILTER_MODE_KO);

 mc = newSWFMovieClip();
 SWFMovieClip_add(mc, shape);
 SWFMovieClip_nextFrame(mc);
 item = SWFMovie_add(m, mc);
 
 SWFDisplayItem_addFilter(item, f);
 SWFMovie_save(m, "shadow.swf");
 return 0;
}
}}}
=== Button Example ===

Filter types

* DropShadowFilter

* BlurFilter

* GlowFilter

* BevelFilter

* GradientGlowFilter

* ConvolutionFilter

* ColorMatrixFilter

* GradientBevelFilter

Usage

Beware: Filter can only be applied to buttons, sprite/movieclips and text instances (aka SWFDisplayItem)!

C

MovieClip DropShadow Example

#include <ming.h>
#include <stdlib.h>
int main()
{
        SWFMovie m;
        SWFShape shape;
        SWFMovieClip mc;
        SWFDisplayItem item;
        SWFBlur blur;
        SWFFilter f;
        SWFShadow shadow;
        SWFColor c;

        Ming_init();
        m = newSWFMovieWithVersion(7);
        if(m == NULL)
                return EXIT_FAILURE;
        
        shape = newSWFShape();

        SWFShape_setLine(shape, 4, 0, 0, 0, 255);
        SWFShape_movePenTo(shape, 50, 50);
        SWFShape_drawLineTo(shape, 0, 10);
        
        blur = newSWFBlur(5,5,1);
        shadow = newSWFShadow(0.79, 2, 1);
        c.red = 0xcf;
        c.green = 0xcf;
        c.blue = 0xcf;
        c.alpha = 0xff;

        f = newDropShadowFilter(c, blur, shadow,  FILTER_MODE_KO);      

        mc = newSWFMovieClip();
        SWFMovieClip_add(mc, shape);
        SWFMovieClip_nextFrame(mc);
        item = SWFMovie_add(m, mc);
        
        SWFDisplayItem_addFilter(item, f);
        SWFMovie_save(m, "shadow.swf");
        return 0;
}

Button Example

int main()
{
        SWFMovie m;
        SWFShape shape;
        SWFButton b;
        SWFDisplayItem item;
        SWFBlur blur;
        SWFFilter f;

        Ming_init();
        m = newSWFMovieWithVersion(7);
        if(m == NULL)
                return EXIT_FAILURE;
        
        shape = newSWFShape();

        SWFShape_setLine(shape, 4, 25, 0, 0, 128);
        SWFShape_movePenTo(shape, 5, 5);
        SWFShape_drawLineTo(shape, 0, 10);
        
        blur = newSWFBlur(5,5,2);
        f = newBlurFilter(blur);

        b = newSWFButton();
        SWFButton_addShape(b, (SWFCharacter)shape,
                SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN);
        item = SWFMovie_add(m, (SWFBlock)b);
        
        SWFDisplayItem_addFilter(item, f);
        SWFMovie_save(m, "test01.swf");
        return 0;
}

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);
$f = new SWFFilter(SWFFILTER_TYPE_BLUR, $bl);

$bu = new SWFButton();
$bu->addShape($s, SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN);
$item = $m->add($bu);
$item->addFilter($f);
$m->save("test01.swf");
?>

libming: HowToUseFilter (last edited 2009-06-25 03:09:39 by localhost)