Depth 1 -> Bottom Depth 3 -> Top

If you put a mask on depth 1 with a MaskLevel of 4 (aka. ClipDepth) all items with depth <= 4 are masked. Items with depth >= 5 are not masked.

Example

//|
//| Copyright (C) Articque Informatique
//| All rights reserved. Duplication and distribution prohibited.
//| Les Roches, 37230 Fondettes France
//| Telephone +33 02.47.49.90.49
//| Fax +33 02.47.49.91.49
//| E-Mail: info@articque.com
//|

// this is a sample to show how to use mask in C++


#include <stdio.h>
#include <mingpp.h>

int main (int argc, const char * argv[]) 
{
  SWFMovie      *movie;
  Ming_useSWFVersion(7);
  movie = new SWFMovie();
  movie->setDimension(100,100);
  // draw a line
  SWFSprite*spline=new SWFSprite();
  SWFShape*shline=new SWFShape();
  shline->setLine(5,0,0,255,255);//thick,r,g,b,[a]
  shline->movePenTo(0,0);
  shline->drawLineTo(100,100);
  spline->add(shline);
  spline->nextFrame();
  SWFDisplayItem*itline=movie->add(spline);
  // draw rect
  SWFSprite*sprect=new SWFSprite();
  SWFShape*shrect=new SWFShape();
  shrect->setLine(1,0,128,0,255);//thick,r,g,b,[a]
  shrect->movePenTo(29,29);
  shrect->drawLineTo(71,29);
  shrect->drawLineTo(71,71);
  shrect->drawLineTo(29,71);
  shrect->drawLineTo(29,29);
  sprect->add(shrect);
  sprect->nextFrame();
  SWFDisplayItem*itrect=movie->add(sprect);
  // build mask for line
  SWFSprite*spmask=new SWFSprite();
  SWFShape*shmask=new SWFShape();
  SWFFill*flmask=shmask->addSolidFill(0,0,0);
  shmask->setRightFill(flmask);
  shmask->movePenTo(30,30);
  shmask->drawLineTo(70,30);
  shmask->drawLineTo(70,70);
  shmask->drawLineTo(30,70);
  shmask->drawLineTo(30,30);
  spmask->add(shmask);
  spmask->nextFrame();
  SWFDisplayItem*itmask=movie->add(spmask);
  // set mask
  itline->setDepth(3);
  itrect->setDepth(5);
  itmask->setDepth(1);
  SWFDisplayItem_setMaskLevel(itmask->item,4);
  // save
  movie->save("image.swf");
  return 0;
}

Display

xxx

libming: HowToUseMasks (last edited 2009-06-25 03:09:40 by localhost)