
#include "ming.h"

int main()
{
  SWFMorph p;
  SWFShape s;
  SWFMovie m;
  SWFDisplayItem i;
  SWFGradient g;
  SWFFill f;

  int n;

  Ming_init();
  Ming_setScale(1.0);

  p = newSWFMorphShape();

  g = newSWFGradient();
  SWFGradient_addEntry(g, 0.0, 0, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.16, 0xff, 0xff, 0xff, 0xff);
  SWFGradient_addEntry(g, 0.32, 0, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.48, 0xff, 0xff, 0xff, 0xff);
  SWFGradient_addEntry(g, 0.64, 0, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.80, 0xff, 0xff, 0xff, 0xff);
  SWFGradient_addEntry(g, 1.00, 0, 0, 0, 0xff);

  s = SWFMorph_getShape1(p);
  f = SWFShape_addGradientFill(s, g, SWFFILL_RADIAL_GRADIENT);
  SWFFill_scaleTo(f, 0.005, 0.005);
  SWFShape_setLeftFill(s, f);
  SWFShape_movePenTo(s, -160, -120);
  SWFShape_drawLine(s, 320, 0);
  SWFShape_drawLine(s, 0, 240);
  SWFShape_drawLine(s, -320, 0);
  SWFShape_drawLine(s, 0, -240);

  g = newSWFGradient();
  SWFGradient_addEntry(g, 0.0, 0, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.16, 0xff, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.32, 0, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.48, 0, 0xff, 0, 0xff);
  SWFGradient_addEntry(g, 0.64, 0, 0, 0, 0xff);
  SWFGradient_addEntry(g, 0.80, 0, 0, 0xff, 0xff);
  SWFGradient_addEntry(g, 1.00, 0, 0, 0, 0xff);

  s = SWFMorph_getShape2(p);
  f = SWFShape_addGradientFill(s, g, SWFFILL_RADIAL_GRADIENT);
  SWFFill_scaleTo(f, 0.008, 0.008);
  SWFFill_skewXTo(f, -0.5);
  SWFShape_setLeftFill(s, f);
  SWFShape_movePenTo(s, -160, -120);
  SWFShape_drawLine(s, 320, 0);
  SWFShape_drawLine(s, 0, 240);
  SWFShape_drawLine(s, -320, 0);
  SWFShape_drawLine(s, 0, -240);

  m = newSWFMovie();
  SWFMovie_setDimension(m, 320, 240);
  i = SWFMovie_add(m, p);
  SWFDisplayItem_moveTo(i, 160, 120);

  for(n=0; n<=100; ++n)
  {
    SWFDisplayItem_setRatio(i, n/100.0);
    SWFMovie_nextFrame(m);
  }

  SWFMovie_save(m, "test.swf");

  exit(0);
}
