René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Masking [Ming wrapper example] | ||
This example creates a mask that can be dragged with the mouse. The mask displays the objects underneath.
This flash movie was created with the following program. Masking.cpp
#include "SWFMovie.h" #include <cmath> void DrawRect(Shape& shape) { shape.FillStyle(std::rand()%255, std::rand()%255, std::rand()%255, std::rand()%127); int w = std::rand()%50+20; int h = std::rand()%50+20; int x = std::rand()%330; int y = std::rand()%330; shape.MoveTo( x, y); shape.Line ( w, 0); shape.Line ( 0, h); shape.Line ( -w, 0); shape.Line ( 0, -h); } int main() { Movie movie("Masking.swf", 400, 400); Shape shape; for (int i=0; i<200; i++) { DrawRect(shape); } Shape mask; mask.LineStyle(5, 0, 0, 0); mask.FillStyle(0,0,255); // mask.Circle(40); mask.Line(100,0); mask.Line(0,100); mask.Line(-100,0); mask.Line(0,-100); MovieClip clip_drag; clip_drag.Add(mask); DisplayClip iMask = movie.Mask(clip_drag, 2); movie.Add (shape, 2); //iMask.OnMouseMove("this._x=_mousex;this._y=_mousey;"); iMask.OnMouseDown("startDrag();"); iMask.OnMouseUp ("stopDrag ();"); clip_drag.NextFrame(); movie.NextFrame(); return 0; } This is one of a series of examples that demonstrates the C++ ming wrapper classes. Other examples can be found here.
|