Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
    /*
     * device_Circle should have the side-effect that a
     * circle is drawn, centred at the given location, with
     * the given radius.
     * (If the device has non-square pixels, 'radius' should
     * be interpreted in the units of the x direction.)
     * The border of the circle should be
     * drawn in the given "col", and the circle should be
     * filled with the given "fill" colour.
     * If "col" is NA_INTEGER then no border should be drawn
     * If "fill" is NA_INTEGER then the circle should not
     * be filled.
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   col, fill, gamma, lty, lwd
     */	
static void SWF_Circle( double x, double y, double r,
		const pGEcontext plotParams, pDevDesc deviceInfo ){
	
	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_Circle: Drawing Circle at x = %f, y = %f, r = %f\n",
			x,y,r);
		fflush(swfInfo->logFile);
	}
	
	SWFShape circle;
	circle = newSWFShape();
	
	SWFShape_movePenTo(circle, x, y);
	/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
	y = deviceInfo->top - y;

	// this is causing the shapes not to be drawn???
	if( plotParams->fill != R_RGBA(255, 255, 255, 0) )
		SWF_SetFill( circle,  plotParams, swfInfo);

	if( plotParams->col != R_RGBA(255, 255, 255, 0) )
		SWF_SetLineStyle( circle,  plotParams, swfInfo);
	
	// draws a circle with radius r 
	// centered at (x,y) into shape circle

	double a = r * 0.414213562; 
	// = tan(22.5 deg)

	double b = r * 0.707106781; 
	// = sqrt(2)/2 = sin(45 deg)

	SWFShape_movePenTo(circle, x + r, y);

	SWFShape_drawCurveTo(circle, x+r, y-a, x+b, y-b); 
	SWFShape_drawCurveTo(circle, x+a, y-r, x  , y-r); 
	SWFShape_drawCurveTo(circle, x-a, y-r, x-b, y-b); 
	SWFShape_drawCurveTo(circle, x-r, y-a, x-r, y  ); 
	SWFShape_drawCurveTo(circle, x-r, y+a, x-b, y+b); 
	SWFShape_drawCurveTo(circle, x-a, y+r, x  , y+r); 
	SWFShape_drawCurveTo(circle, x+a, y+r, x+b, y+b); 
	SWFShape_drawCurveTo(circle, x+r, y+a, x+r, y  );
	
	
	// I would like to use this function but the circles 
	// drawn with it are funky
	//SWFShape_drawCircle(circle, r);

	SWFDisplayItem circled = SWFMovie_add(swfInfo->m, (SWFBlock) circle);

	addToDisplayList( circled );
			
}
Ejemplo n.º 3
0
static void MingSWFCircle(double x, double y, double r, const pGEcontext gc, pDevDesc RGD)
{
	MingSWFDesc *MGD = (MingSWFDesc *)RGD->deviceSpecific;
	SWFShape circle = newSWFShape();
	SWFMovieClip mcCircle;
	SWFDisplayItem display_item;
	char strBuffer[1024];

	mcCircle = newSWFMovieClip();
	sprintf(strBuffer,"var Label = \"x=<b>%.2f</b>, y=%.2f\\nradius is %.2f\";",x,y,r);
	SWFMovieClip_add(mcCircle, (SWFBlock) newSWFAction(strBuffer));


	if (gc->fill){
		SWFShape fcircle; 
		SWFFillStyle fill;
		fcircle = newSWFShape();
		SWFShape_movePenTo(fcircle, x, y);
		MINGSWF_SET_COLOR(MGD,gc->fill);
		fill = newSWFSolidFillStyle(MGD->red,MGD->green,MGD->blue,MGD->alpha);
        SWFShape_setRightFillStyle(fcircle, fill);
		Fixed_SWFShape_drawCircle(fcircle, r<2.0?2.0:r, 0 , 360);
		/*SWFMovie_add(MGD->movie, (SWFBlock) fcircle);*/
		SWFMovieClip_add(mcCircle, (SWFBlock) fcircle);
	}

	SWFShape_movePenTo(circle, x, y);
	MINGSWF_SET_COLOR(MGD,gc->col);
	MINGSWF_SET_LINE(MGD,circle,gc);
	/* curve drawing is flawed with setLine2() for some reason */
	/*SWFShape_setLine(circle,gc->lwd,MGD->red,MGD->green,MGD->blue,MGD->alpha);*/

	/* SWFShape_drawCircle(circle, (int)(r<2.0?2.0:r)); */
	Fixed_SWFShape_drawCircle(circle, r<2.0?2.0:r, 0 , 360);
	/*SWFDisplayItem_moveTo(SWFMovie_add(MGD->movie, (SWFBlock) circle) , x, y);*/
	/* SWFMovie_add(MGD->movie, (SWFBlock) circle);*/
	/* destroySWFShape(circle); */
	if (gc->fill){
		/*destroySWFFillStyle(fill);*/
	}

	SWFMovieClip_add(mcCircle, (SWFBlock) circle);
	SWFMovieClip_nextFrame(mcCircle);

	/* Add Label Actions */
	MingSWF_SetLabelActions(SWFMovie_add(MGD->movie, (SWFBlock) mcCircle));

#ifdef MINGSWFDEBUG
	Rprintf("Circle(x=%f,y=%f,r=%f,gc=0x%x,RGD=0x%x)\n",x,y,r,gc,RGD);
	Rprintf("\tuser coords: x=%f,y=%f\n",fromDeviceX(x,GE_NDC,MGD->RGE),fromDeviceY(y,GE_NDC,MGD->RGE));
#endif
}
Ejemplo n.º 4
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
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
    /*
     * device_Line should have the side-effect that a single
     * line is drawn (from x1,y1 to x2,y2)
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   col, gamma, lty, lwd
     */
static void SWF_Line( double x1, double y1, double x2, 
	double y2, const pGEcontext plotParams, pDevDesc deviceInfo )
{
	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;
	
	//If debugging, print info to log file
	if(swfInfo->debug == TRUE){
		fprintf(swfInfo->logFile,
			"SWF_Line: Drawing line from (%6.1f, %6.1f) to (%6.1f, %6.1f)\n",
			x1,y1,x2,y2);
		fflush(swfInfo->logFile);
	}
	
	SWFShape line = newSWFShape();
	/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
	y1 = deviceInfo->top - y1;
	y2 = deviceInfo->top - y2;
	
	
	SWFShape_movePenTo(line, x1, y1);
	
	if( plotParams->col != R_RGBA(255, 255, 255, 0) )
		SWF_SetLineStyle(line, plotParams, swfInfo);
	
	//Respect lty	
	SWF_drawStyledLineTo(line, x2, y2, plotParams->lty);
	

	SWFDisplayItem lined = SWFMovie_add(swfInfo->m, (SWFBlock) line);
	
	addToDisplayList( lined );
	
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
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);
}
Ejemplo n.º 9
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);

}
Ejemplo n.º 10
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
}
Ejemplo n.º 11
0
static VALUE move_pen_to(VALUE self, VALUE x, VALUE y)
{
  SWFShape shape;

  Data_Get_Struct(self, struct SWFShape_s, shape);

  SWFShape_movePenTo(shape, NUM2DBL(x), NUM2DBL(y));
  return self;
}
Ejemplo n.º 12
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);
}
Ejemplo n.º 13
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;
}
Ejemplo n.º 14
0
int outlineMoveTo(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_movePenTo(shape, dx, dy);

    return 0;
}
Ejemplo n.º 15
0
void swfLine(double x1, double y1, double x2, double y2, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("line called\n");
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape shape = newSWFShape();
    swfSetLineStyle(shape, gc, swfInfo);
    
    SWFShape_movePenTo(shape, x1, y1);
    swfDrawStyledLineTo(shape, x2, y2, gc);
    SWFShape_end(shape);
    SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) shape);
}
Ejemplo n.º 16
0
	/*
     * device_Polyline should have the side-effect that a
     * series of line segments are drawn using the given x
     * and y values.
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   col, gamma, lty, lwd
     */
static void SWF_Polyline( int n, double *x, double *y,
		pGEcontext plotParams, pDevDesc deviceInfo )
{
	
	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;	
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_Polyline: Drawing Polyline\n");
		fflush(swfInfo->logFile);
	}
	
	SWFShape line;
	line = newSWFShape();
	
	if( plotParams->col != R_RGBA(255, 255, 255, 0) )
		SWF_SetLineStyle(line, plotParams, swfInfo);
	
	
	/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
	y[0] = deviceInfo->top - y[0];
	
	/* Start the pen at the first point */
	SWFShape_movePenTo(line, x[0], y[0]);
	
	if( swfInfo->debug == TRUE )
		fprintf(swfInfo->logFile,
			"\t\t(%5.1f,%5.1f)\n",x[0], y[0]);
	
	/* Print coordinates for the middle segments of the line. */
	int i;
	for ( i = 1; i < n; i++ ){
		
		/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
		y[i] = deviceInfo->top - y[i];
		
		SWF_drawStyledLineTo(line, x[i], y[i], plotParams->lty);	
		
		if( swfInfo->debug == TRUE )
			fprintf(swfInfo->logFile,
				"\t\t(%5.1f,%5.1f)\n", x[i], y[i]);
	}
	
	SWFDisplayItem lined = SWFMovie_add(swfInfo->m, (SWFBlock) line);
	
	addToDisplayList( lined );

}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
0
void swfCircle(double x, double y, double r, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("circle called\n");
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape shape = newSWFShape();
    swfSetLineStyle(shape, gc, swfInfo);
    swfSetFillStyle(shape, gc, swfInfo);
    
    SWFShape_movePenTo(shape, x, y);
    SWFShape_drawCircle(shape, r);
    SWFShape_end(shape);
    SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) shape);
}
Ejemplo n.º 19
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;
}
Ejemplo n.º 20
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
}
Ejemplo n.º 21
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);
    }
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
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;
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
void swfPolyline(int n, double *x, double *y, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("polyline called\n");
    Rprintf("** polyline(n = %d, (x0, y0) = (%f, %f), (x1, y1) = (%f, %f))\n",
        n, x[0], y[0], x[1], y[1]);
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape shape = newSWFShape();
    int i = 0;
    
    swfSetLineStyle(shape, gc, swfInfo);
    
    SWFShape_movePenTo(shape, x[0], y[0]);
    for(i = 1; i < n; i++)
    {
        swfDrawStyledLineTo(shape, x[i], y[i], gc);
    }
    SWFShape_end(shape);
    SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) shape);
}
Ejemplo n.º 26
0
void
add_window(SWFMovie mo, int x, int y)
{
	SWFShape sh_window;
	SWFFillStyle fstyle;
	SWFMovieClip mc_window;
	SWFDisplayItem it;

	sh_window = newSWFShape();
	fstyle = SWFShape_addSolidFillStyle(sh_window, 0,0,0,255);
	SWFShape_setRightFillStyle(sh_window, fstyle);
	SWFShape_movePenTo(sh_window, 170, 170);
	SWFShape_drawLine(sh_window, -170, 0);
	SWFShape_drawLine(sh_window, 0, -170);
	SWFShape_drawLine(sh_window, 170, 0);
	SWFShape_drawLine(sh_window, 0, 170);

	mc_window = newSWFMovieClip();
	SWFMovieClip_add(mc_window, (SWFBlock)sh_window);
	SWFMovieClip_add(mc_window, (SWFBlock)newSWFAction(
		"_root.xcheck(getBytesLoaded() < _root.getBytesLoaded());"
		"_root.xcheck(getBytesTotal() < _root.getBytesTotal());"
	));
	SWFMovieClip_nextFrame(mc_window); /* showFrame */

	it = SWFMovie_add(mo, (SWFBlock)mc_window);
	SWFDisplayItem_setName(it, "window"); 
	SWFDisplayItem_moveTo(it, x, y);

    SWFDisplayItem_addAction(it, compileSWFActionCode(
        "_root.note('Click on \"Load PNG\" to load a PNG movie here.');"
        ),
		SWFACTION_ROLLOVER);

	SWFDisplayItem_addAction(it, compileSWFActionCode(
		"delete _level0.window.onMouseDown;"
		),
		SWFACTION_ROLLOUT);

}
Ejemplo n.º 27
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);
}
Ejemplo n.º 28
0
static void
ming_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
		int arrow_at_end, int filled)
{
    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+=3)
	SWFShape_drawCubicTo(shape,
		A[i].x, A[i].y, A[i+1].x, A[i+1].y, A[i+2].x, A[i+2].y);
    SWFMovie_add(movie, (SWFBlock)shape);
}
Ejemplo n.º 29
0
	/*
     * device_Rect should have the side-effect that a
     * rectangle is drawn with the given locations for its
     * opposite corners.  The border of the rectangle
     * should be in the given "col" colour and the rectangle
     * should be filled with the given "fill" colour.
     * If "col" is NA_INTEGER then no border should be drawn
     * If "fill" is NA_INTEGER then the rectangle should not
     * be filled.
     */
static void SWF_Rectangle( double x0, double y0, double x1, 
	double y1, const pGEcontext plotParams, pDevDesc deviceInfo ){

	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;

	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_Rectangle: Drawing Rectangle\n");
		fflush(swfInfo->logFile);
	}
			
	SWFShape rectangle;
	rectangle = newSWFShape();
	/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
	y0 = deviceInfo->top - y0;
	y1 = deviceInfo->top - y1;

	if( plotParams->col != R_RGBA(255, 255, 255, 0) )
		SWF_SetLineStyle(rectangle, plotParams, swfInfo);
		
	if( plotParams->fill != R_RGBA(255, 255, 255, 0) )
		SWF_SetFill(rectangle, plotParams, swfInfo);

	/* Start the pen at the first point */
	SWFShape_movePenTo(rectangle, x0, y0);

	/* Draw the four line segments on the rectangle */
	SWF_drawStyledLineTo(rectangle, x0, y1, plotParams->lty);
	SWF_drawStyledLineTo(rectangle, x1, y1, plotParams->lty);
	SWF_drawStyledLineTo(rectangle, x1, y0, plotParams->lty);
	SWF_drawStyledLineTo(rectangle, x0, y0, plotParams->lty);

	SWFDisplayItem rectangled = SWFMovie_add(swfInfo->m, (SWFBlock) rectangle);
	
	addToDisplayList( rectangled );
			
}
Ejemplo n.º 30
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);
    }
}