Example #1
0
void swfClip(double x0, double x1, double y0, double y1, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("clip called\n");
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape shape = newSWFShape();
    SWFFillStyle fill;
    
    /* Set previous clip layer to the appropriate depth */
    if(swfInfo->currentClip)
    {
        SWFDisplayItem_endMask(swfInfo->currentClip);
    }
    
    /* Create new clip layer */
    fill = newSWFSolidFillStyle(0xFF, 0xFF, 0xFF, 0xFF);
    SWFShape_setRightFillStyle(shape, fill);
    SWFArray_append(swfInfo->array, (SWFObject) fill);
    
    SWFShape_movePenTo(shape, x0, y0);
    SWFShape_drawLineTo(shape, x1, y0);
    SWFShape_drawLineTo(shape, x1, y1);
    SWFShape_drawLineTo(shape, x0, y1);
    SWFShape_drawLineTo(shape, x0, y0);
    SWFShape_end(shape);
    swfInfo->currentClip = SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) shape);
    SWFDisplayItem_setMaskLevel(swfInfo->currentClip, 99999);
}
Example #2
0
int main()
{
	int i;
	SWFMovie m = newSWFMovieWithVersion(8);

	SWFShape shape1 = newSWFShape();
	SWFShape shape2 = newSWFShape();
	
	SWFShape_setLine2(shape1, 1, 25, 0, 0, 128, SWF_LINESTYLE_FLAG_HINTING, 0);
	SWFShape_movePenTo(shape1, 5, 5);
        SWFShape_drawLineTo(shape1, 50, 30);

	SWFShape_setLine2(shape2, 1, 25, 100, 100, 255, SWF_LINESTYLE_FLAG_HINTING, 0);
	SWFShape_movePenTo(shape2, 5, 5);
        SWFShape_drawLineTo(shape2, 50, 130);

	SWFDisplayItem item = SWFMovie_add(m, shape1);
	SWFMovie_nextFrame(m);
	SWFMovie_replace(m, item, shape2);
	SWFMovie_nextFrame(m);

	SWFMovie_save(m,"test01.swf");

	return 0;
}
Example #3
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);
}
Example #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);

}
Example #5
0
void
make_shape(SWFShape sh, int x, int y, int width, int height, byte r, byte g, byte b)
{
  SWFFillStyle fs = SWFShape_addSolidFillStyle(sh, r, g, b, 255);
  SWFShape_setLineStyle(sh, 1, r, g, b, 255);
  SWFShape_setLeftFillStyle(sh, fs);
  SWFShape_movePenTo(sh, x, y);
  SWFShape_drawLineTo(sh, x, y+height);
  SWFShape_drawLineTo(sh, x+width, y+height);
  SWFShape_drawLineTo(sh, x+width, y);
  SWFShape_drawLineTo(sh, x, y);
}
Example #6
0
static SWFShape
make_square(int x, int y, int width, int height, byte r, byte g, byte b)
{
	SWFShape sh = newSWFShape();
	SWFShape_setLineStyle(sh, 1, r, g, b, 255);
	SWFShape_movePenTo(sh, x, y);
	SWFShape_drawLineTo(sh, x, y+height);
	SWFShape_drawLineTo(sh, x+width, y+height);
	SWFShape_drawLineTo(sh, x+width, y);
	SWFShape_drawLineTo(sh, x, y);

	return sh;
}
Example #7
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;
}
Example #8
0
SWFShape
make_fill_square(int x, int y, int width, int height, byte or, byte og, byte ob, byte fr, byte fg, byte fb)
{
	SWFShape sh = newSWFShape();
	SWFFillStyle fs = SWFShape_addSolidFillStyle(sh, fr, fg, fb, 255);
	SWFShape_setLineStyle(sh, 1, or, og, ob, 255);
	SWFShape_setLeftFillStyle(sh, fs);
	SWFShape_movePenTo(sh, x, y);
	SWFShape_drawLineTo(sh, x, y+height);
	SWFShape_drawLineTo(sh, x+width, y+height);
	SWFShape_drawLineTo(sh, x+width, y);
	SWFShape_drawLineTo(sh, x, y);

	return sh;
}
Example #9
0
int main()
{
	SWFMovie m = newSWFMovieWithVersion(8);

	SWFShape shape = newSWFShape();
	
        SWFShape_setLine(shape, 4, 25, 0, 0, 128);
	SWFShape_movePenTo(shape, 5, 5);
        SWFShape_drawLineTo(shape, 50, 100);
	SWFShape_drawLineTo(shape, 100, 100);

	SWFMovie_add(m, (SWFBlock)shape);
	SWFMovie_save(m, "test01.swf");

	return 0;
}
Example #10
0
static void MingSWFPolyline(int n, double *x, double *y, const pGEcontext gc, pDevDesc RGD)
{
	int i = 1;
	MingSWFDesc *MGD = (MingSWFDesc *)RGD->deviceSpecific;
	SWFShape line = newSWFShape();

	MINGSWF_SET_COLOR(MGD,gc->col);
	MINGSWF_SET_LINE(MGD,line,gc);

	SWFShape_movePenTo(line,x[0],y[0]);
	while (i<n) { 
		SWFShape_drawLineTo(line, x[i], y[i]); 
		i++; 
	}

	/*SWFDisplayItem_moveTo(SWFMovie_add(MGD->movie, (SWFBlock) line),0,0);*/
	SWFMovie_add(MGD->movie, (SWFBlock) line);
	/*destroySWFShape(line);*/
#ifdef MINGSWFDEBUG
	{ int i=0;
	Rprintf("Polyline(n=%d,x=0x%x,y=0x%x,gc=0x%x,RGD=0x%x)\n\tpoints: ",n,x,y,gc,RGD);
	while(i<n){ Rprintf("(%.2f,%.2f) ",x[i],y[i]); i++;} Rprintf("\n");
	}
#endif
}
Example #11
0
static void
add_rectangle (SWFMovieClip clip, int r, int g, int b)
{
  SWFShape shape;
  SWFFillStyle fill;

  shape = newSWFShape ();
  fill = SWFShape_addSolidFillStyle (shape, r, g, b, 255);
  SWFShape_setRightFillStyle (shape, fill);
  SWFShape_drawLineTo (shape, 50, 0);
  SWFShape_drawLineTo (shape, 50, 50);
  SWFShape_drawLineTo (shape, 0, 50);
  SWFShape_drawLineTo (shape, 0, 0);

  SWFMovieClip_add (clip, (SWFBlock) shape);
}
Example #12
0
static void MingSWFPolygon(int n, double *x, double *y, const pGEcontext gc, pDevDesc RGD)
{
	int i;
	MingSWFDesc *MGD = (MingSWFDesc *)RGD->deviceSpecific;
	SWFShape line = newSWFShape();


	if (gc->fill){
		SWFShape fline;
        SWFFillStyle fill;
	   	fline = newSWFShape();
		MINGSWF_SET_COLOR(MGD,gc->fill);
		fill = newSWFSolidFillStyle(MGD->red,MGD->green,MGD->blue,MGD->alpha);
        SWFShape_setRightFillStyle(fline, fill);
		SWFShape_movePenTo(fline,x[0],y[0]);
		i = 1;
		while (i<n) { 
			SWFShape_drawLineTo(fline, x[i], y[i]); 
			i++; 
		}
		/* For some reason fills bleed. So ensure they don't  */
		if (((int)x[0] != (int)x[n-1]) || ((int)y[0]!=(int)y[n-1]))
			SWFShape_drawLineTo(fline, x[0], y[0]); 
		SWFMovie_add(MGD->movie, (SWFBlock) fline);
	}

	MINGSWF_SET_COLOR(MGD,gc->col);
	MINGSWF_SET_LINE(MGD,line,gc);

	SWFShape_movePenTo(line,x[0],y[0]);
	i = 1;
	while (i<n) { 
		SWFShape_drawLineTo(line, x[i], y[i]); 
		i++; 
	}

	/*SWFDisplayItem_moveTo(SWFMovie_add(MGD->movie, (SWFBlock) line),0,0);*/
	SWFMovie_add(MGD->movie, (SWFBlock) line);
	/*destroySWFShape(line);*/
#ifdef MINGSWFDEBUG
	{ int i=0;
	Rprintf("Polygon(n=%d,x=0x%x,y=0x%x,gc=0x%x,RGD=0x%x)\n\tpoints: ",n,x,y,gc,RGD);
	while(i<n){ Rprintf("(%.2f,%.2f) ",x[i],y[i]); i++;} Rprintf("\n");
	}
#endif
}
Example #13
0
int main()
{
	SWFMovie m = newSWFMovieWithVersion(8);

	SWFShape shape = newSWFShape();
	
	SWFShape_setLine2(shape, 40, 25, 0, 0, 128, 
		SWF_LINESTYLE_FLAG_HINTING | SWF_LINESTYLE_JOIN_BEVEL | SWF_LINESTYLE_FLAG_ENDCAP_SQUARE, 0);
	SWFShape_movePenTo(shape, 5, 5);
        SWFShape_drawLineTo(shape, 50, 100);
	SWFShape_drawLineTo(shape, 100, 100);

	SWFMovie_add(m, (SWFBlock)shape);
	SWFMovie_save(m,"test02.swf");

	return 0;
}
Example #14
0
static VALUE draw_line_to(VALUE self, VALUE x, VALUE y)
{
  SWFShape shape;

  Data_Get_Struct(self, struct SWFShape_s, shape);

  SWFShape_drawLineTo(shape, NUM2DBL(x), NUM2DBL(y));
  return self;
}
Example #15
0
int outlineLineTo(const FT_Vector* to, void* user)
{
    OutlineData *data = (OutlineData *) user;
    SWFShape shape = data->shape;
    double ratio_EM = data->ratio_EM;

    double dx = to->x * ratio_EM + data->deltax;
    double dy = -to->y * ratio_EM;

    SWFShape_drawLineTo(shape, dx, dy);

    return 0;
}
Example #16
0
void swfPolygon(int n, double *x, double *y, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("polygon called\n");
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape shape = newSWFShape();
    int i = 0;
    
    /* First fill the polygon with no stroke, then draw polyline additionally */
    swfSetFillStyle(shape, gc, swfInfo);
    
    SWFShape_movePenTo(shape, x[0], y[0]);
    for(i = 1; i < n; i++)
    {
        SWFShape_drawLineTo(shape, x[i], y[i]);
    }
    SWFShape_drawLineTo(shape, x[0], y[0]);
    SWFShape_end(shape);
    SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) shape);
    swfPolyline(n, x, y, gc, dd);
}
Example #17
0
static void MingSWFLine(double x1, double y1, double x2, double y2, const pGEcontext gc, pDevDesc RGD)
{
	MingSWFDesc *MGD = (MingSWFDesc *)RGD->deviceSpecific;
	SWFShape line = newSWFShape();

	MINGSWF_SET_COLOR(MGD,gc->col);
	MINGSWF_SET_LINE(MGD,line,gc);

	SWFShape_movePenTo(line, x1, y1);
	SWFShape_drawLineTo(line, x2, y2);
	SWFMovie_add(MGD->movie, (SWFBlock) line);

#ifdef MINGSWFDEBUG
	Rprintf("Line(x0=%f,y0=%f,x1=%f,y1=%f,gc=0x%x,RGD=0x%x)\n",x1,y1,x2,y2,gc,RGD);
#endif
}
Example #18
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);
    }
}
Example #19
0
int main()
{
	SWFMovie m;
	SWFShape shape;
	SWFButton b;
	SWFDisplayItem item;
	SWFBlur blur;
	SWFFilter f;
	SWFShadow shadow;
	SWFColor c1, c2;

	Ming_init();
	m = newSWFMovieWithVersion(7);
	if(m == NULL)
		return EXIT_FAILURE;
	
	shape = newSWFShape();

	SWFShape_setLine(shape, 4, 25, 0, 0, 128);	
	SWFShape_movePenTo(shape, 5, 5);
	SWFShape_drawLineTo(shape, 0, 10);
	
	blur = newSWFBlur(5,5,2);
	shadow = newSWFShadow(0.79, 5, 1.0);
	
	c1.red = 0;
	c1.green = 0;
	c1.blue = 0;
	c1.alpha = 0xff;

	c2.red = 0xff;
	c2.green = 0xff;
	c2.blue = 0xff;
	c2.alpha = 0xff;
	f = newBevelFilter(c1, c2, blur, shadow, FILTER_MODE_INNER | FILTER_MODE_KO);	

	b = newSWFButton();
	SWFButton_addCharacter(b, (SWFCharacter)shape,
		SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN);
	item = SWFMovie_add(m, (SWFBlock)b);
	
	SWFDisplayItem_addFilter(item, f);
	SWFMovie_save(m, "test04.swf");
	return 0;
}
Example #20
0
static void
ming_polyline(GVJ_t * job, pointf * A, int n)
{
    SWFMovie movie = (SWFMovie)(job->context);
    SWFShape shape;
    obj_state_t *obj = job->obj;
    gvcolor_t pencolor = obj->pencolor;
    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]);
    SWFShape_movePenTo(shape, A[0].x, A[0].y);
    for (i = 1; i < n; i++)
	SWFShape_drawLineTo(shape, A[i].x, A[i].y);
    SWFMovie_add(movie, (SWFBlock)shape);
}
Example #21
0
int main(int argc, char *argv[])
{
   SWFMovie movie;
   SWFMorph p;
   SWFShape shape_1;
   SWFGradient grad_1;
   SWFFill fill1;
   SWFShape shape_2;
   SWFGradient grad_2;
   SWFFill fill2;
   SWFDisplayItem timeline;
   float n;

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

   p= newSWFMorphShape();

   grad_1= newSWFGradient();
   SWFGradient_addEntry(grad_1, 0, 0x00, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_1, 0.16, 0xFF, 0xFF, 0xFF, 0xFF);
   SWFGradient_addEntry(grad_1, 0.32, 0x00, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_1, 0.48, 0xFF, 0xFF, 0xFF, 0xFF);
   SWFGradient_addEntry(grad_1, 0.64, 0x00, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_1, 0.8, 0xFF, 0xFF, 0xFF, 0xFF);
   SWFGradient_addEntry(grad_1, 1, 0x00, 0x00, 0x00, 0xFF);

   shape_1= SWFMorph_getShape1(p);
   fill1= SWFShape_addGradientFill(shape_1,grad_1, SWFFILL_RADIAL_GRADIENT);
   SWFFill_scaleTo(fill1, 0.100, 0.100);
   SWFShape_setLeftFill(shape_1, fill1);
   SWFShape_movePenTo(shape_1, -160.00, -120.00);
   SWFShape_drawLineTo(shape_1, 160.00, -120.00);
   SWFShape_drawLineTo(shape_1, 160.00, 120.00);
   SWFShape_drawLineTo(shape_1, -160.00, 120.00);
   SWFShape_drawLineTo(shape_1, -160.00, -120.00);

   grad_2= newSWFGradient();
   SWFGradient_addEntry(grad_2, 0, 0x00, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_2, 0.16, 0xFF, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_2, 0.32, 0x00, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_2, 0.48, 0x00, 0xFF, 0x00, 0xFF);
   SWFGradient_addEntry(grad_2, 0.64, 0x00, 0x00, 0x00, 0xFF);
   SWFGradient_addEntry(grad_2, 0.8, 0x00, 0x00, 0xFF, 0xFF);
   SWFGradient_addEntry(grad_2, 1, 0x00, 0x00, 0x00, 0xFF);

   shape_2= SWFMorph_getShape2(p);
   fill2= SWFShape_addGradientFill(shape_2,grad_2, SWFFILL_RADIAL_GRADIENT);

   SWFFill_scaleTo(fill2, 0.16, 0.16);
   SWFFill_skewXTo(fill2, -0.50);
   //SWFFill_rotateTo(fill2, -26.57);

   SWFShape_setLeftFill(shape_2, fill2);
   SWFShape_movePenTo(shape_2, -160.00, -120.00);
   SWFShape_drawLineTo(shape_2, 160.00, -120.00);
   SWFShape_drawLineTo(shape_2, 160.00, 120.00);
   SWFShape_drawLineTo(shape_2, -160.00, 120.00);
   SWFShape_drawLineTo(shape_2, -160.00, -120.00);

   timeline= SWFMovie_add(movie,(SWFBlock) p);
   SWFDisplayItem_moveTo(timeline, 160.00, 120.00);

   for(n=0; n<=1.001; n+=0.01)
   {
      SWFDisplayItem_setRatio(timeline, n);
      SWFMovie_nextFrame(movie);
   }

   SWFMovie_save(movie, "gradientxform.swf");

   return 0;
}
Example #22
0
void swfDrawStyledLineTo(SWFShape shape, double x, double y, const pGEcontext gc)
{
    int lty = gc->lty;
    int lwd = gc->lwd;
    /* Original positions */
    double x0 = SWFShape_getPenX(shape);
    double y0 = SWFShape_getPenY(shape);
    double x_next, y_next;
    /* Distance between (x0, y0) and (x, y) */
    double dist = sqrt(pow(x - x0, 2) + pow(y - y0, 2));
    
    unsigned char dashlist[8];
    int ndash = 0;
    /* Length of one cycle of dashlines */
    int cycle_len = 0;
    /* How many full cycles will we have in drawing the line? */
    int ncycle = 0;
    /* How many pen-up and pen-down segments? */
    int nseg = 0;
    /* Distance the pen has moved */
    /* s is a temp variable */
    double dist_moved = 0.0, s = 0.0;
    int i;
    
    /* Is the pen for next segment up or down? */
    Rboolean is_down = TRUE;
    
    /* If it is a solid line */
    /* NOTE: Here lty == 0 corresponds to lty = 1 in R */
    if(lty == LTY_SOLID) /* LTY_SOLID == 0 */
    {
        SWFShape_drawLineTo(shape, x, y);
        return;
    }
    if(lty == LTY_BLANK) /* LTY_BLANK == -1 */
    {
        SWFShape_movePenTo(shape, x, y);
        return;
    }

    /* Decode texture description */
    for(i = 0; i < 8 && lty & 15; i++)
    {
        dashlist[ndash++] = lty & 15;
        lty = lty >> 4;
        cycle_len += dashlist[i];
    }
    
    /* Cycle length proportional to lwd */
    cycle_len *= lwd;
    ncycle = (int) floor(dist / cycle_len);
    nseg = ncycle * ndash;
    /* Length of the last incomplete cycle */
    s = dist - cycle_len * ncycle;
    for(i = 0; i < ndash; i++)
    {
        if(dist_moved + dashlist[i] * lwd >= s)
            break;

        dist_moved += dashlist[i] * lwd;
        nseg++;
    }

    dist_moved = 0.0;
    for(i = 0; i < nseg; i++)
    {
        dist_moved += dashlist[i % ndash] * lwd;
        x_next = x0 + dist_moved / dist * (x - x0);
        y_next = y0 + dist_moved / dist * (y - y0);
        if(is_down)
        {
            SWFShape_drawLineTo(shape, x_next, y_next);
        } else {
            SWFShape_movePenTo(shape, x_next, y_next);
        }
        is_down = !is_down;
    }
    if(is_down)
    {
        SWFShape_drawLineTo(shape, x, y);
    } else {
        SWFShape_movePenTo(shape, x, y);
    }
}
Example #23
0
EXPORT BOOL WINAPI s_drawLineTo(float x, float y, int p3, int p4)
{
	lstrcpy(funcname, "s_drawLineTo");
	SWFShape_drawLineTo(mhsp_shape, x, y);
	return 0;
}
Example #24
0
static void SWF_drawStyledLineTo(SWFShape line, double x_end, 
	double y_end, int lty)
{
	byte dashlist[8];
	int i, nlty;
	
	/* From ?par
	 * Line types can either be specified by giving an index into a small 
	 * built-in table of line types (1 = solid, 2 = dashed, etc, see lty 
	 * above) or directly as the lengths of on/off stretches of line. This 
	 * is done with a string of an even number (up to eight) of characters, 
	 * namely non-zero (hexadecimal) digits which give the lengths in 
	 * consecutive positions in the string. For example, the string "33" 
	 * specifies three units on followed by three off and "3313" specifies 
	 * three units on followed by three off followed by one on and finally 
	 * three off. The ‘units’ here are (on most devices) proportional to lwd, 
	 * and with lwd = 1 are in pixels or points or 1/96 inch.

	 * The five standard dash-dot line types (lty = 2:6) correspond to 
	 * c("44", "13", "1343", "73", "2262").
	 * 
	 * (0=blank, 1=solid (default), 2=dashed, 
	 *  3=dotted, 4=dotdash, 5=longdash, 6=twodash) 
	*/
	
	/*Retrieve the line type pattern*/
	for(i = 0; i < 8 && lty & 15 ; i++) {
		dashlist[i] = lty & 15;
		lty = lty >> 4;
		//if( DEBUG == TRUE )
		//	Rprintf("\tDash List: %d\n", dashlist[i]);
	}
	nlty = i; i = 0;
	
	if(nlty == 0){
		SWFShape_drawLineTo(line, x_end, y_end);
		return;
	}
	
		/* Do the drawing of dashed line manually
		 * this is very sucky, it sould be done for me
		 * In my opinion, this is a huge limitation of libming.
		 *
		 * 1. Calculate end point of dash segment
		 * 2a. If past end point of line, draw to end of line, end
		 * 2b. Otherwise draw to end point of dash segment
		 * 3. Repeat
		 */
		
		//Current position
	double x_cur = SWFShape_getPenX(line);
	//double y1 = GEcurrentDevice()->dev->top - SWFShape_getPenY(line);
	double y_cur = SWFShape_getPenY(line);
	
		//end of dash segment
	double x_next, y_next, ang = atan((y_end-y_cur)/(x_end-x_cur));
		//distance to end of dash segment and end of line
	double d_dash, d_line = 10000, old_d_line;
	Rboolean at_line_end = FALSE;
	
	//Rprintf("x_cur=%f x_end=%f\n",x_cur,x_end);
	//Rprintf("y_cur=%f y_end=%f\n",y_cur,y_end);
	
	while( at_line_end == FALSE ){
		while(i < nlty){
			//Rprintf("INNER LOOP\n");
			
			/*
			 * This part is so whacked out, basically the different origins of 
			 * R and ming make drawing dashed lines REALLY confusing. This 
			 * seems to work though :). A lot of things in R graphics seem to
			 * go this way. 
			*/
			if(x_end < x_cur && y_end <= y_cur){
				x_next = x_cur - (double)dashlist[i] * cos(ang);
				y_next = y_cur - (double)dashlist[i] * sin(ang);
			}
			if(x_end > x_cur && y_end <= y_cur){
				x_next = x_cur + (double)dashlist[i] * cos(ang);
				y_next = y_cur + (double)dashlist[i] * sin(ang);
			}
			if(x_end < x_cur && y_end > y_cur){
				x_next = x_cur - (double)dashlist[i] * cos(ang);
				y_next = y_cur - (double)dashlist[i] * sin(ang);
			}
			if(x_end > x_cur && y_end > y_cur){
				x_next = x_cur + (double)dashlist[i] * cos(ang);
				y_next = y_cur + (double)dashlist[i] * sin(ang);
			}
			
			old_d_line = d_line;
			d_line = sqrt(pow(abs(x_end-x_cur),2)+pow(abs(y_end-y_cur),2));
			d_dash = sqrt(pow(abs(x_next-x_cur),2)+pow(abs(y_next-y_cur),2));

			//Rprintf("i=%d nlty=%d\n",i,nlty);
			//Rprintf("x_cur=%f x_end=%f x_next=%f\n",x_cur,x_end,x_next);
			//Rprintf("y_cur=%f y_end=%f y_next=%f\n",y_cur,y_end,y_next);
			//Rprintf("ang=%f\n",ang);
			//Rprintf("d_dash=%f\n",d_dash);
			//Rprintf("d_line=%f\n",d_line);
			//Rprintf("old_d_line=%f\n",old_d_line);
			
			if( (d_dash >= d_line) || old_d_line < d_line ){
				//Rprintf("%s\n\n\n","Time to break");
				if( (i % 2) == 0 ){
						//draw to the end of the line segment
					SWFShape_drawLineTo(line, x_end, y_end);
				}else{
					SWFShape_movePenTo(line, x_end, y_end);
				}
				at_line_end = TRUE; //out of main loop
				break; //out of inner loop
			}
				
			if( (i % 2) == 0 ){
					//draw to the end point of the dash segment
				SWFShape_drawLineTo(line, x_next, y_next);
				//if( DEBUG == TRUE )
				//Rprintf("\tDrawing dash line to: (%f,%f)\n", x_next, y_next);
			}else{
				SWFShape_movePenTo(line, x_next, y_next);
				//if( DEBUG == TRUE )
				//Rprintf("\tMoving dash pen to: (%f,%f)\n", x_next, y_next);
			}
			// Update coordinates
			x_cur = x_next; y_cur = y_next; 
			i++;
		}
		i = 0;
	}
		
}
Example #25
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;
}
Example #26
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip mc1, mc2, dejagnuclip;
  SWFDisplayItem it;
  SWFShape  sh1,sh2;
  SWFAction ac1, ac2;
  int i;

  const char *srcdir=".";
  if ( argc>1 ) 
    srcdir=argv[1];
  else
  {
      //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
      //return 1;
  }

  Ming_init();
  mo = newSWFMovie();
  SWFMovie_setDimension(mo, 800, 600);
  //SWFMovie_setRate (mo, 1.0);

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); 

  sh1 = make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  sh2 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 0, 0, 0);
  
  it = SWFMovie_add(mo, (SWFBlock)sh1);  
  SWFDisplayItem_setName(it, "sh1"); 
  SWFDisplayItem_setDepth(it, 3); //place the sh1 DisplayObject at depth 3;
  
  it = SWFMovie_add(mo, (SWFBlock)sh2);  
  SWFDisplayItem_setName(it, "sh2"); 
  SWFDisplayItem_setDepth(it, 4); //place the sh2 DisplayObject at depth 4;

  check(mo, "sh1 != undefined");
  check(mo, "sh2 != undefined");
  
  // Do these checks mean that shapes are movieclips?
  // seems not.
  check_equals(mo, "typeof(sh1)", "'movieclip'");
  check_equals(mo, "typeof(sh2)", "'movieclip'");
  check_equals(mo, "typeof(_root)", "'movieclip'");
  
  add_actions(mo, 
    "sh1.var1 = 10;"
    "sh2.var2 = 20;"
    );

  // Do these checks mean that we can add variables to shapes?
  // seems not, variable are added to the _root, interesting.
  check_equals(mo, "sh1.var1", "10");
  check_equals(mo, "sh2.var2", "20");
  check_equals(mo, "_root.var1", "10");
  check_equals(mo, "_root.var2", "20");
  
  check_equals(mo, "sh1._x", "0");
  check_equals(mo, "sh2._x", "0");

  add_actions(mo, 
    "sh1._x = 0;"
    "sh2._x = 400;"
    );

  check_equals(mo, "sh1._x", "400");
  check_equals(mo, "sh2._x", "400");
  check_equals(mo, "_root._x", "400");

  add_actions(mo, "_root._x = 0;" ); /* cleanup */
    
  // Do these checks mean that shapes are *not* movieclips?
  check_equals(mo, "typeof(sh1.getDepth())", "'undefined'");
  check_equals(mo, "typeof(sh2.getDepth())", "'undefined'");
    
  // Do these checks mean that shapes are *not* movieclips?
  check_equals(mo, "typeof(getInstanceAtDepth(-16381))", "'undefined'");
  check_equals(mo, "typeof(getInstanceAtDepth(-16380))", "'undefined'");

  SWFMovie_nextFrame(mo); 

  /*
   * UdoG's drawing
   *
   * See DrawingApiTest.as (inv8)
   *
   */
  { /*  using left fill, non-closed paths */
	SWFDisplayItem it1, it2;
	SWFShape sh = newSWFShape();
	SWFMovieClip mc = newSWFMovieClip();
	SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255);
	SWFShape_setLeftFillStyle(sh, SWFShape_addSolidFillStyle(sh, 0, 255, 0, 255));
	SWFShape_movePenTo(sh, 20, 10);		/* 0 */
	SWFShape_drawLineTo(sh, 40, 10);	/* 1 */
	SWFShape_drawLineTo(sh, 40, 40);	/* 2 */
	SWFShape_drawLineTo(sh, 20, 40);	/* 3 */
	SWFShape_drawLineTo(sh, 20, 10);	/* 4 */
	SWFShape_drawLineTo(sh, 10, 10);	/* 5 */
	SWFShape_drawLineTo(sh, 10, 20);	/* 6 */
	SWFShape_drawLineTo(sh, 30, 20);	/* 7 */
	SWFShape_drawLineTo(sh, 30, 30);	/* 8 */
	SWFShape_drawLineTo(sh, 20, 30);	/* 9 */
	it1 = SWFMovieClip_add(mc, (SWFBlock)sh);

	// Test that clip events are not invoked for shapes
#if 0 // current Ming HEAD chokes if we add an onClipConstruct event... 
	SWFDisplayItem_addAction(it1, newSWFAction( 
		"_root.check(false && 'clip event for shape should not be executed');"
		SWFACTION_CONSTRUCT);
#endif
	SWFDisplayItem_addAction(it1, newSWFAction( 
		"_root.check(false && 'clip event for shape should not be executed');"
		), SWFACTION_ENTERFRAME);
	SWFDisplayItem_addAction(it1, newSWFAction( 
		"_root.check(false && 'clip event for shape should not be executed');"
		), SWFACTION_ONLOAD);
	SWFDisplayItem_addAction(it1, newSWFAction( 
		"_root.check(false && 'clip event for shape should not be executed');"
		), SWFACTION_UNLOAD);
	SWFDisplayItem_addAction(it1, newSWFAction( 
		"_root.check(false && 'clip event for shape should not be executed');"
		), SWFACTION_MOUSEMOVE);
	SWFDisplayItem_addAction(it1, newSWFAction( 
		"_root.check(false && 'clip event for shape should not be executed');"
		), SWFACTION_MOUSEDOWN);
	// None of these should be executed
	SWFDisplayItem_addAction(it1, newSWFAction(
		"_root.check(false && 'clip event for shape should not be executed');"
		), SWFACTION_ONLOAD);

	SWFDisplayItem_moveTo(it1, 80, 120);
	SWFDisplayItem_scale(it1, 2, 2);
	SWFMovieClip_nextFrame(mc);
	it2 = SWFMovie_add(mo, (SWFBlock)mc);
  }
  { /*  using right fill, non-closed paths */
	SWFDisplayItem it;
	SWFShape sh = newSWFShape();
	SWFMovieClip mc = newSWFMovieClip();
	SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255);
	SWFShape_setLeftFillStyle(sh, SWFShape_addSolidFillStyle(sh, 0, 255, 0, 255));
	SWFShape_movePenTo(sh, 20, 10);		/* 0 */
	SWFShape_drawLineTo(sh, 40, 10);	/* 1 */
	SWFShape_drawLineTo(sh, 40, 40);	/* 2 */
	SWFShape_drawLineTo(sh, 20, 40);	/* 3 */
	SWFShape_drawLineTo(sh, 20, 10);	/* 4 */
	SWFShape_drawLineTo(sh, 10, 10);	/* 5 */
	SWFShape_drawLineTo(sh, 10, 20);	/* 6 */
	SWFShape_drawLineTo(sh, 30, 20);	/* 7 */
	SWFShape_drawLineTo(sh, 30, 30);	/* 8 */
	SWFShape_drawLineTo(sh, 20, 30);	/* 9 */
	it = SWFMovieClip_add(mc, (SWFBlock)sh);
	SWFDisplayItem_moveTo(it, 200, 120);
	SWFDisplayItem_scale(it, 2, 2);
	SWFMovieClip_nextFrame(mc);
	it = SWFMovie_add(mo, (SWFBlock)mc);
  }
  { /*  using left fill, closed paths */
	SWFDisplayItem it;
	SWFShape sh = newSWFShape();
	SWFMovieClip mc = newSWFMovieClip();
	SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255);
	SWFShape_setLeftFillStyle(sh, SWFShape_addSolidFillStyle(sh, 255, 0, 0, 255));
	SWFShape_movePenTo(sh, 20, 10);		/* 0 */
	SWFShape_drawLineTo(sh, 40, 10);	/* 1 */
	SWFShape_drawLineTo(sh, 40, 40);	/* 2 */
	SWFShape_drawLineTo(sh, 20, 40);	/* 3 */
	SWFShape_drawLineTo(sh, 20, 10);	/* 4 */
	SWFShape_drawLineTo(sh, 10, 10);	/* 5 */
	SWFShape_drawLineTo(sh, 10, 20);	/* 6 */
	SWFShape_drawLineTo(sh, 30, 20);	/* 7 */
	SWFShape_drawLineTo(sh, 30, 30);	/* 8 */
	SWFShape_drawLineTo(sh, 20, 30);	/* 9 */
	SWFShape_drawLineTo(sh, 20, 10);	/* 0 */
	it = SWFMovieClip_add(mc, (SWFBlock)sh);
	SWFDisplayItem_moveTo(it, 80, 200);
	SWFDisplayItem_scale(it, 2, 2);
	SWFMovieClip_nextFrame(mc);
	it = SWFMovie_add(mo, (SWFBlock)mc);
  }
  { /*  using right fill, closed paths */
	SWFDisplayItem it;
	SWFShape sh = newSWFShape();
	SWFMovieClip mc = newSWFMovieClip();
	SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255);
	SWFShape_setRightFillStyle(sh, SWFShape_addSolidFillStyle(sh, 255, 0, 0, 255));
	SWFShape_movePenTo(sh, 20, 10);		/* 0 */
	SWFShape_drawLineTo(sh, 40, 10);	/* 1 */
	SWFShape_drawLineTo(sh, 40, 40);	/* 2 */
	SWFShape_drawLineTo(sh, 20, 40);	/* 3 */
	SWFShape_drawLineTo(sh, 20, 10);	/* 4 */
	SWFShape_drawLineTo(sh, 10, 10);	/* 5 */
	SWFShape_drawLineTo(sh, 10, 20);	/* 6 */
	SWFShape_drawLineTo(sh, 30, 20);	/* 7 */
	SWFShape_drawLineTo(sh, 30, 30);	/* 8 */
	SWFShape_drawLineTo(sh, 20, 30);	/* 9 */
	SWFShape_drawLineTo(sh, 20, 10);	/* 0 */
	it = SWFMovieClip_add(mc, (SWFBlock)sh);
	SWFDisplayItem_moveTo(it, 200, 200);
	SWFDisplayItem_scale(it, 2, 2);
	SWFMovieClip_nextFrame(mc);
	it = SWFMovie_add(mo, (SWFBlock)mc);
  }

  add_actions(mo, "_root.totals(); stop();");

  SWFMovie_nextFrame(mo); 

  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}