Esempio n. 1
0
int main(int argc, char *argv[])
{
    SWFMovie movie;
    SWFShape shape1;
    SWFGradient grad_1;
    SWFFill fill1;
    SWFDisplayItem timeline;
    SWFShape shape2;
    SWFGradient grad_2;
    SWFFill fill2;

    Ming_init(argc, argv);
    Ming_useSWFVersion(5);
    movie= newSWFMovie();
    SWFMovie_setDimension(movie, 320, 240);

    shape1= newSWFShape();

    /* first gradient- black to white */
    grad_1= newSWFGradient();
    SWFGradient_addEntry(grad_1, 0, 0x00, 0x00, 0x00, 0xFF);
    SWFGradient_addEntry(grad_1, 1, 0xFF, 0xFF, 0xFF, 0xFF);

    fill1= SWFShape_addGradientFill(shape1, grad_1, SWFFILL_LINEAR_GRADIENT);
    SWFFill_scaleTo(fill1, 0.170, 0.170);
    SWFFill_moveTo(fill1, 160.00, 120.00);
    SWFShape_setRightFill(shape1, fill1);
    SWFShape_drawLineTo(shape1, 320.00, 0.00);
    SWFShape_drawLineTo(shape1, 320.00, 240.00);
    SWFShape_drawLineTo(shape1, 0.00, 240.00);
    SWFShape_drawLineTo(shape1, 0.00, 0.00);

    timeline= SWFMovie_add(movie, (SWFBlock) shape1);
    /* SWFDisplayItem_moveTo(timeline, 0.00, 0.00);*/

    shape2= newSWFShape();

    /* second gradient- radial gradient from white to red to transparent */
    grad_2= newSWFGradient();
    SWFGradient_addEntry(grad_2, 0, 0xFF, 0x00, 0x00, 0xFF);
    SWFGradient_addEntry(grad_2, 1, 0xFF, 0x00, 0x00, 0x00);

    fill2= SWFShape_addGradientFill(shape2, grad_2, SWFFILL_RADIAL_GRADIENT);
    SWFFill_scaleTo(fill2, 0.120, 0.120);
    SWFFill_moveTo(fill2, 160.00, 120.00);
    SWFShape_setRightFill(shape2, fill2);
    SWFShape_drawLineTo(shape2, 320.00, 0.00);
    SWFShape_drawLineTo(shape2, 320.00, 240.00);
    SWFShape_drawLineTo(shape2, 0.00, 240.00);
    SWFShape_drawLineTo(shape2, 0.00, 0.00);

    timeline= SWFMovie_add(movie, (SWFBlock) shape2);

    SWFMovie_nextFrame(movie);

    SWFMovie_save(movie, "gradient.swf");

    return 0;
}
Esempio n. 2
0
static void
ming_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
    SWFMovie movie = (SWFMovie)(job->context);
    SWFShape shape;
    SWFFill fill;
    obj_state_t *obj = job->obj;
    gvcolor_t pencolor = obj->pencolor;
    gvcolor_t fillcolor = obj->fillcolor;
    int i;

    shape = newSWFShape();
    SWFShape_setLine(shape, obj->penwidth,
	 pencolor.u.rgba[0],
	 pencolor.u.rgba[1],
	 pencolor.u.rgba[2],
	 pencolor.u.rgba[3]);
    if (filled) {
	fill = SWFShape_addSolidFill(shape,
	    fillcolor.u.rgba[0],
	    fillcolor.u.rgba[1],
	    fillcolor.u.rgba[2],
	    fillcolor.u.rgba[3]);
	SWFShape_setRightFill(shape, fill);
    }
    SWFShape_movePenTo(shape, A[0].x, A[0].y);
    for (i = 1; i < n; i++)
	SWFShape_drawLineTo(shape, A[i].x, A[i].y);
    SWFShape_drawLineTo(shape, A[0].x, A[0].y);
    SWFMovie_add(movie, (SWFBlock)shape);
}
Esempio n. 3
0
static void ming_ellipse(GVJ_t * job, pointf * A, int filled)
{
    SWFMovie movie = (SWFMovie)(job->context);
    SWFShape shape;
    SWFFill fill;
    SWFDisplayItem item;
    obj_state_t *obj = job->obj;
    gvcolor_t pencolor = obj->pencolor;
    gvcolor_t fillcolor = obj->fillcolor;
    double rx, ry;

    shape = newSWFShape();
    SWFShape_setLine(shape, obj->penwidth,
	 pencolor.u.rgba[0],
	 pencolor.u.rgba[1],
	 pencolor.u.rgba[2],
	 pencolor.u.rgba[3]);
    if (filled) {
	fill = SWFShape_addSolidFill(shape,
	    fillcolor.u.rgba[0],
	    fillcolor.u.rgba[1],
	    fillcolor.u.rgba[2],
	    fillcolor.u.rgba[3]);
	SWFShape_setRightFill(shape, fill);
    }
    SWFShape_movePenTo(shape, 0, 0);
    rx = A[1].x - A[0].x;
    ry = A[1].y - A[0].y;
    SWFShape_drawCircle(shape, rx);
    item = SWFMovie_add(movie, (SWFBlock)shape);
    SWFDisplayItem_scale(item, 1., ry/rx);
    SWFDisplayItem_moveTo(item, A[0].x, A[0].y);
}
Esempio n. 4
0
static void
embed_image(SWFMovie movie, char *f)
{
	SWFFill fill;
	SWFBitmap bm;
	SWFShape shape;
	SWFMovieClip clip;
	SWFDisplayItem it, it2;
	FILE *raster;
	SWFInput in;
	int height, width;
	char *name;

        if (!(raster = fopen (f, "rb")))
        {
                fprintf (stdout, "%s: %s\n", f, strerror (errno));
		exit(1);
        }

        if (!(in = newSWFInput_file(raster)))
        {
                fprintf (stdout, "Can't create SWFInput from file\n");
		exit(1);
        }

        if (!(bm = newSWFBitmap_fromInput (in)))
        {
                fprintf (stdout, "Error creating bitmap");
		exit(1);
        }

	height = SWFBitmap_getHeight(bm);
	width = SWFBitmap_getWidth(bm);


	shape = newSWFShape();
  
	SWFShape_movePenTo(shape, 0, 0);

	fill = SWFShape_addBitmapFill(shape, bm, SWFFILL_CLIPPED_BITMAP);
	SWFShape_setRightFill(shape, fill);
	SWFShape_drawLineTo(shape, width, 0);
	SWFShape_drawLineTo(shape, width, height);
	SWFShape_drawLineTo(shape, 0, height);
	SWFShape_drawLineTo(shape, 0, 0);

	clip = newSWFMovieClip();
	it2 = SWFMovieClip_add(clip, (SWFBlock)shape);
	SWFMovieClip_nextFrame(clip);

	it = SWFMovie_add(mo, (SWFBlock)clip);

	name = base_name(f);

	SWFDisplayItem_setName(it, name);

	free(name);

}
Esempio n. 5
0
static VALUE set_right_fill(VALUE self, VALUE _fill)
{
  SWFShape shape;
  SWFFill fill;

  Data_Get_Struct(self, struct SWFShape_s, shape);
  Data_Get_Struct(_fill, struct SWFFill_s, fill);

  SWFShape_setRightFill(shape, fill);
  return self;
}
Esempio n. 6
0
static void
out_splines (SWFMovie m, spline_list_array_type shape, int height)
{
  unsigned this_list;
  color_type last_color = {0,0,0};

  for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape);
    this_list++)
      {
        SWFShape k;

        unsigned this_spline;
        spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list);
        spline_type first = SPLINE_LIST_ELT (list, 0);

        if (this_list == 0 || !COLOR_EQUAL(list.color, last_color))
		  {
            k = newSWFShape();
            SWFShape_setRightFill(k, SWFShape_addSolidFill(k, list.color.r, list.color.g, list.color.b, 0xff));
	        last_color = list.color;
		  }
        SWFShape_movePenTo(k, SWFSCALE*START_POINT(first).x,
			     SWFSCALE*height - SWFSCALE*START_POINT(first).y);

        for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list);
          this_spline++)
          {
            spline_type s = SPLINE_LIST_ELT (list, this_spline);

            if (SPLINE_DEGREE(s) == LINEARTYPE)
              {
                SWFShape_drawLineTo(k, SWFSCALE*END_POINT(s).x,
                  SWFSCALE*height - SWFSCALE*END_POINT(s).y);
              }
            else
              {
                SWFShape_drawCubicTo (k, SWFSCALE*CONTROL1(s).x,
                  SWFSCALE*height - SWFSCALE*CONTROL1(s).y,
                  SWFSCALE*CONTROL2(s).x,
                  SWFSCALE*height - SWFSCALE*CONTROL2(s).y,
                  SWFSCALE*END_POINT(s).x,
                  SWFSCALE*height - SWFSCALE*END_POINT(s).y);
              }
          }
        SWFMovie_add(m,k);
    }
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
   SWFMovie m;
   SWFShape shape;
   SWFBitmap b;
   SWFFill fill;
   SWFDisplayItem i;
   FILE *file_bitmap;
   float n;
   float height;
   float width;
   char *imageFile = "backyard.jpg";

   Ming_init(argc, argv);
   Ming_useSWFVersion(5);
   m = newSWFMovie();

   shape = newSWFShape();

   if(!(file_bitmap = fopen(imageFile,"rb")))
   {   
      printf("Couldn't find file '%s'", imageFile);   
   }

   b = (SWFCharacter) newSWFJpegBitmap(file_bitmap);


   SWFMovie_setDimension(m, SWFBitmap_getWidth(b), SWFBitmap_getHeight(b));

   fill = SWFShape_addBitmapFill(shape, b, SWFFILL_TILED_BITMAP);

   SWFShape_setRightFill(shape, fill);

   height = (float) SWFBitmap_getHeight(b);
   width = (float) SWFBitmap_getWidth(b);
   SWFShape_drawLineTo(shape, width, 0.00);
   SWFShape_drawLineTo(shape, width, height);
   SWFShape_drawLineTo(shape, 0.00, height);
   SWFShape_drawLineTo(shape, 0.00, 0.00);


   i = SWFMovie_add(m, (SWFBlock) shape);

   for(n=0; n<20.0; ++n)
   {
      SWFDisplayItem_multColor(i, 1.0- n/10.0, 1.0, 1.0, 1.0);
      SWFDisplayItem_addColor(i, 0xff* n/20.0, 0, 0, 0);
      SWFMovie_nextFrame(m);
   }

   for(n=20.0; n>0; --n)
   {
      SWFDisplayItem_multColor(i, 1.0- n/10.0, 1.0, 1.0, 1.0);
      SWFDisplayItem_addColor(i, 0xff* n/20.0, 0, 0, 0);
      SWFMovie_nextFrame(m);
   }

   SWFMovie_save(m, "cxform.swf");

   fclose(file_bitmap); /* Do not close earlier or an error will happen */
   return 0;
}
Esempio n. 8
0
EXPORT BOOL WINAPI s_setRightFill(SWFFill fill, int p2, int p3, int p4)
{
	lstrcpy(funcname, "s_setLeftFill");
	SWFShape_setRightFill(mhsp_shape, fill);
	return 0;
}