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
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;
}
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
int main()
{
	SWFMovie m = newSWFMovieWithVersion(8);
	SWFDBLBitmapData img = newSWFDBLBitmapData_fromPngFile(MEDIADIR "/image01.png");
	if ( ! img )
	{
		fprintf(stderr, "Could not create bitmap from png file "MEDIADIR"/image01.png\n");
		return EXIT_FAILURE;
	}
	
	SWFFillStyle fill = newSWFBitmapFillStyle((SWFCharacter)img, SWFFILL_CLIPPED_BITMAP);
	if ( ! fill )
	{
		fprintf(stderr, "Could not create bitmap from file "MEDIADIR"/image01.png\n");
		return EXIT_FAILURE;
	}

	SWFShape shape = newSWFShape();
	SWFShape_setRightFillStyle(shape, fill);
	
	SWFShape_setLine(shape, 1, 0,0,0,255);
	SWFShape_drawLine(shape, 100, 0);
	SWFShape_drawLine(shape, 0, 100);
	SWFShape_drawLine(shape, -100, 0);
	SWFShape_drawLine(shape, 0, -100);

	SWFMovie_add(m, (SWFBlock)shape);
	SWFMovie_save(m, "test05.swf");
	return 0;

}
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
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.º 9
0
int main()
{
	SWFMovie m = newSWFMovieWithVersion(8);
	FILE *file = fopen(MEDIADIR "/image01.dbl", "rb");
	if(file == NULL)
	{
		perror(MEDIADIR "/image01.dbl");
		exit(EXIT_FAILURE);
	}

	SWFDBLBitmap img = newSWFDBLBitmap(file);
	SWFFillStyle fill = newSWFBitmapFillStyle((SWFCharacter)img, SWFFILL_CLIPPED_BITMAP);
	SWFShape shape = newSWFShape();
	SWFShape_setRightFillStyle(shape, fill);
	
	SWFShape_setLine(shape, 1, 0,0,0,255);
	SWFShape_drawLine(shape, 100, 0);
	SWFShape_drawLine(shape, 0, 100);
	SWFShape_drawLine(shape, -100, 0);
	SWFShape_drawLine(shape, 0, -100);

	SWFMovie_add(m, (SWFBlock)shape);
	SWFMovie_save(m, "test04.swf");
	return 0;

}
Ejemplo n.º 10
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.º 11
0
/*
 * Creates a shape filled with bitmap
 */
SWFShape
newSWFShapeFromBitmap(SWFBitmap bitmap, int flag)
{
    SWFShape shape = newSWFShape();
    SWFFillStyle fill;
    int width, height;

    if ( flag != SWFFILL_TILED_BITMAP && flag != SWFFILL_CLIPPED_BITMAP)
    {
        SWF_error("Invalid bitmap fill flag");
    }

    fill = SWFShape_addBitmapFillStyle(shape, bitmap, flag);

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

    SWFShape_setRightFillStyle(shape, fill);

    // XXX - scale shouldn't be hardcoded! (here, or in newSWFBitmapFillStyle)
    SWFShape_drawScaledLine(shape, width * 20, 0);
    SWFShape_drawScaledLine(shape, 0, height * 20);
    SWFShape_drawScaledLine(shape, -width * 20, 0);
    SWFShape_drawScaledLine(shape, 0, -height * 20);

    return shape;
}
Ejemplo n.º 12
0
/* TODO: respect hadj */
void swfTextUTF8(double x, double y, const char *str, double rot, double hadj, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("textUTF8 called\n");
    Rprintf("** family = %s, font = %d\n", gc->fontfamily, gc->fontface);
    Rprintf("** textUTF8(str[0] = %d, str[1] = %d, str[2] = %d, str[3] = %d)\n",
            str[0], str[1], str[2], str[3]);
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape text = newSWFShape();
    SWFDisplayItem text_display;
    /* Convert UTF-8 string to Unicode array */
    int maxLen = strlen(str);
    wchar_t *unicode = (wchar_t *) calloc(maxLen + 1, sizeof(wchar_t));
    int len = utf8towcs(unicode, str, maxLen);
    
    FT_Face face = swfGetFTFace(gc, swfInfo);
    double fontSize = gc->ps * gc->cex;

    swfSetTextColor(text, gc, swfInfo);
    SWFShape_addString(text, unicode, len, fontSize, face,
                       &(swfInfo->outlnFuns));
    
    text_display = SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) text);
    SWFDisplayItem_moveTo(text_display, x, y);
    SWFDisplayItem_rotate(text_display, rot);
}
Ejemplo n.º 13
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.º 14
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.º 15
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.º 16
0
EXPORT BOOL WINAPI mhsp_SWFShape(SWFShape *p1, int p2, int p3, int p4)
{
	lstrcpy(funcname, "SWFShape");
	*p1 = newSWFShape();
	if (!mhsp_shape) {
		mhsp_shape = *p1;
	}
	return 0;
}
Ejemplo n.º 17
0
int main()
{
	SWFMovie m = newSWFMovieWithVersion(8);
	SWFShape shape1 = newSWFShape();
	SWFShape_addSolidFill(shape1, 32, 64, 128, 223);
	SWFShape_addSolidFill(shape1, 64, 128, 32, 24);
	SWFMovie_add(m, (SWFBlock)shape1);
	SWFMovie_save(m, "test01.swf");

	return EXIT_SUCCESS;
}
Ejemplo n.º 18
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.º 19
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.º 20
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.º 21
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.º 22
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.º 23
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.º 24
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);
}
Ejemplo n.º 25
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.º 26
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.º 27
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.º 28
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.º 29
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.º 30
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);
}