
#include "ming.h"

int main()
{
  SWFShape s, c;
  SWFFill f;
  SWFMovie m;
  SWFDisplayItem i;

  int x, y;

  Ming_init();
  Ming_setScale(1.0);

  s = newSWFShape();

  // .msk file generated with "gif2mask" utility
  f = SWFShape_addBitmapFill(s, newSWFJpegWithAlpha(fopen("../common/alphafill.jpg", "rb"),
													fopen("../common/alphafill.msk", "rb")),
							 SWFFILL_TILED_BITMAP);

  SWFShape_setRightFill(s, f);

  SWFShape_drawLine(s, 640, 0);
  SWFShape_drawLine(s, 0, 480);
  SWFShape_drawLine(s, -640, 0);
  SWFShape_drawLine(s, 0, -480);

  c = newSWFShape();
  SWFShape_setRightFill(c, SWFShape_addSolidFill(c, 0x99, 0x99, 0x99, 0xff));
  SWFShape_drawLine(c, 40, 0);
  SWFShape_drawLine(c, 0, 40);
  SWFShape_drawLine(c, -40, 0);
  SWFShape_drawLine(c, 0, -40);

  m = newSWFMovie();
  SWFMovie_setDimension(m, 640, 480);
  SWFMovie_setBackground(m, 0xcc, 0xcc, 0xcc);

  // draw checkerboard background
  for(y=0; y<480; y+=40)
  {
    for(x=0; x<640; x+=80)
    {
      i = SWFMovie_add(m, c);
      SWFDisplayItem_moveTo(i, x, y);
    }

    y+=40;

    for(x=40; x<640; x+=80)
    {
      i = SWFMovie_add(m, c);
      SWFDisplayItem_moveTo(i, x, y);
    }
  }

  SWFMovie_add(m, s);

  SWFMovie_save(m, "test.swf");

  exit(0);
}
