René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Adding and multiplying colors [Ming wrapper example]

This exmample demonstrates how colors are added and multiplied.
Note, it takes a while until the movie is finished...
This flash movie was created with the following program.
ColorAddMult.cpp
#include "SWFMovie.h"

void rect(Shape& shape) {
  shape.Line( 50,  0);
  shape.Line(  0, 50);
  shape.Line(-50,  0);
  shape.Line(  0,-50);
}

int main() {
  Movie   movie ("ColorAddMult.swf", 175, 175, 50);

  Shape      shape_red  ;
  Shape      shape_black;

  shape_black.FillStyle(  0,0,0);
  shape_red  .FillStyle(255,0,0);

  rect(shape_red  );
  rect(shape_black);

  DisplayItem iShapeAdd__black = movie.Add(shape_black);
  DisplayItem iShapeAdd__red   = movie.Add(shape_red  );
  DisplayItem iShapeMult_black = movie.Add(shape_black);
  DisplayItem iShapeMult_red   = movie.Add(shape_red  );

  iShapeAdd__black.MoveTo( 25, 25);
  iShapeAdd__red  .MoveTo(100, 25);
  iShapeMult_black.MoveTo( 25,100);
  iShapeMult_red  .MoveTo(100,100);

  for (float f=-255;f<255;f+=1) {
    int i=int(f);
    iShapeAdd__black.AddColor (           i,            0,           0);
    iShapeAdd__red  .AddColor (           i,            0,           0);

    iShapeMult_black.MultColor( (f+255)/512, (f+255)/512 ,(f+255)/512 );
    iShapeMult_red  .MultColor( (f+255)/512, (f+255)/512 ,(f+255)/512 );
    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.