Пример #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);
}
Пример #2
0
/* R uses gc->col for text color, but actually we need to "fill" the outlines */
void swfSetTextColor(SWFShape shape, const pGEcontext gc, pswfDesc swfInfo)
{
    SWFFillStyle fill;
    fill = newSWFSolidFillStyle(R_RED(gc->col),
                                R_GREEN(gc->col),
                                R_BLUE(gc->col),
                                R_ALPHA(gc->col));
    SWFShape_setRightFillStyle(shape, fill);
    
    SWFArray_append(swfInfo->array, (SWFObject) fill);
}
Пример #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
}
Пример #4
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
}
Пример #5
0
static void SWF_SetFill(SWFShape shape, const pGEcontext plotParams, 
	swfDevDesc *swfInfo  ){
	
	/*
	 *	Some Notes on Color
	 *
	 *	R uses a 24-bit color model.  Colors are specified in 32-bit
	 *	integers which are partitioned into 4 bytes as follows.
	 *
	 *		<-- most sig	    least sig -->
	 *		+-------------------------------+
	 *		|   0	| blue	| green |  red	|
	 *		+-------------------------------+
	 *
	 *	The red, green and blue bytes can be extracted as follows.
	 *
	 *		red   = ((color	     ) & 255)
	 *		green = ((color >>  8) & 255)
	 *		blue  = ((color >> 16) & 255)
	 */
	
	byte red = R_RED(plotParams->fill);
	byte green = R_GREEN(plotParams->fill);
	byte blue = R_BLUE(plotParams->fill);
	
	//Top 8 bits: 255 = opaque, 0 = transparent
	byte alpha = R_ALPHA(plotParams->fill);
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,"\tFill: Red=%d, ",red);
		fprintf(swfInfo->logFile,"Green=%d, ",green);
		fprintf(swfInfo->logFile,"Blue=%d, ",blue);
		fprintf(swfInfo->logFile,"Alpha=%d\n",alpha);
		fflush(swfInfo->logFile);
	}
		
		
		
	
	SWFFillStyle fill_style;
	fill_style = newSWFSolidFillStyle( red, green, blue, alpha );
	if(fill_style == NULL)
		error("Failed to allocate memory for fill object!");
	SWFShape_setRightFillStyle(shape, fill_style);
}
Пример #6
0
SWFFillStyle
SWFShape_addSolidFillStyle(SWFShape shape, byte r, byte g, byte b, byte a)
{
    int  ret;

    SWFFillStyle fill = newSWFSolidFillStyle(r, g, b, a);

    ret = addFillStyle(shape, fill);
    if(ret < 0) /* error */
    {
        destroySWFFillStyle(fill);
        return NULL;
    }
    else if(ret == shape->nFills)  /* new fill */
    {
        return fill;
    }
    else /* fill is known */
    {
        destroySWFFillStyle(fill);
        return shape->fills[ret];
    }
}
Пример #7
0
void SWF_addPlayerControls(double *x, double *y){
	
	//Get the device info by pointer since this can be called from R
	pDevDesc deviceInfo = GEcurrentDevice()->dev;
	
	// Shortcut pointers to variables of interest. 
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;
	
	// General variables
	SWFDisplayItem          playd;
	SWFDisplayItem          stopd;
	
	// Fill styles we create
	SWFFillStyle            dark_blue_fill;
	SWFFillStyle            red_fill;
	SWFFillStyle            green_fill;
	
	// Variables used for the play button
	SWFAction               play_action;
	SWFButton               play_button;
	SWFButtonRecord         play_record_down;
	SWFButtonRecord         play_record_up;
	SWFShape                play_shape_down;
	SWFShape                play_shape_up;
	
	// Variables used for the stop button
	SWFAction               stop_action;
	SWFButton               stop_button;
	SWFButtonRecord         stop_record_down;
	SWFButtonRecord         stop_record_up;
	SWFShape                stop_shape_down;
	SWFShape                stop_shape_up;
	
	if(swfInfo->haveControls == FALSE){
		
		swfInfo->haveControls = TRUE;
		// Ensure the movie starts out in the "stopped" state
	    SWFMovie_add(swfInfo->m, (SWFBlock) newSWFAction("_root.stop();"));
		
	}
		
	swfInfo->ControlsX = *x;
	swfInfo->ControlsY = deviceInfo->top - *y;
	
	// Create the fill styles we'll be using
	red_fill = newSWFSolidFillStyle(0xf0, 0x00, 0x00, 0x99);
	dark_blue_fill = newSWFSolidFillStyle(0x00, 0x00, 0x90, 0x99);
	green_fill = newSWFSolidFillStyle(0x00, 0xcc, 0x00, 0x99);
	
	// *** Create the Play button ***
	
	// Create a shape to be used in the play button for its "UP" state
	play_shape_up = newSWFShape();
	// Use the dark blue fill
	SWFShape_setRightFillStyle(play_shape_up, green_fill);  
	SWFShape_setLine(play_shape_up, 1, 0x00, 0x00, 0x00, 0xff);
	SWFShape_movePenTo(play_shape_up, swfInfo->ControlsX-25, swfInfo->ControlsY);
	SWFShape_drawLine(play_shape_up,  20,  15);
	SWFShape_drawLine(play_shape_up, -20,  15);
	SWFShape_drawLine(play_shape_up,   0, -30);
	
	// Create a shape to be used in the play button for its "DOWN" state
	play_shape_down = newSWFShape();
	// Use the green fill
	SWFShape_setRightFillStyle(play_shape_down, dark_blue_fill);  
	SWFShape_setLine(play_shape_down, 1, 0x00, 0x00, 0x00, 0xff);
	SWFShape_movePenTo(play_shape_down, swfInfo->ControlsX-25, swfInfo->ControlsY);
	SWFShape_drawLine(play_shape_down,  20,  15);
	SWFShape_drawLine(play_shape_down, -20,  15);
	SWFShape_drawLine(play_shape_down,   0, -30);
	
	// Create an empty button object we can use
	play_button = newSWFButton();
	
	// Add the shapes to the button for its various states
	play_record_up = SWFButton_addCharacter(play_button, 
		(SWFCharacter) play_shape_up, 
		SWFBUTTON_UP|SWFBUTTON_HIT|SWFBUTTON_OVER);
	play_record_down = SWFButton_addCharacter(play_button, 
		(SWFCharacter) play_shape_down, SWFBUTTON_DOWN);
	
	// Add the Play action to the play button 
	play_action = newSWFAction("_root.play();");
	SWFButton_addAction(play_button, play_action, SWFBUTTON_MOUSEUP);
	
	// *** Create the Stop button ***
	
	// Create a shape to be used in the stop button for its "UP" state
	stop_shape_up = newSWFShape();
		// Use the green fill
	SWFShape_setRightFillStyle(stop_shape_up, red_fill);  
	SWFShape_setLine(stop_shape_up, 1, 0x00, 0x00, 0x00, 0xff);
	SWFShape_movePenTo(stop_shape_up, 
		swfInfo->ControlsX , swfInfo->ControlsY + 2.5);
	SWFShape_drawLine(stop_shape_up,  25,  0);
	SWFShape_drawLine(stop_shape_up,   0, 25);
	SWFShape_drawLine(stop_shape_up, -25,  0);
	SWFShape_drawLine(stop_shape_up,  0, -25);
	
	// Create a shape to be used in the stop button for its "DOWN" state
	stop_shape_down = newSWFShape();
	// Use the dark blue fill
	SWFShape_setRightFillStyle(stop_shape_down, dark_blue_fill);  
	SWFShape_setLine(stop_shape_down, 1, 0x00, 0x00, 0x00, 0xff);
	SWFShape_movePenTo(stop_shape_down, 
		swfInfo->ControlsX , swfInfo->ControlsY + 2.5);
	SWFShape_drawLine(stop_shape_down,  25,   0);
	SWFShape_drawLine(stop_shape_down,   0,  25);
	SWFShape_drawLine(stop_shape_down, -25,   0);
	SWFShape_drawLine(stop_shape_down,   0, -25);
	
	// Create an empty button object we can use
	stop_button = newSWFButton();
	
	// Add the shapes to the button for its various states
	stop_record_up = SWFButton_addCharacter(stop_button, 
		(SWFCharacter) stop_shape_up, 
		SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER);
	stop_record_down = SWFButton_addCharacter(stop_button, 
		(SWFCharacter) stop_shape_down, SWFBUTTON_DOWN);
	
	// Add the Stop action to the stop button
	stop_action = newSWFAction("_root.stop();");
	SWFButton_addAction(stop_button, stop_action, SWFBUTTON_MOUSEUP);
	
	// *** Create the movie clip container for the buttons ***
	
	// Embed the buttons in a movie clip
	//movie_clip = newSWFMovieClip();
	playd = SWFMovie_add(swfInfo->m, (SWFBlock) play_button);
	stopd = SWFMovie_add(swfInfo->m, (SWFBlock) stop_button);
	addToDisplayList( playd );
	addToDisplayList( stopd );

    // Advance the movie clip one frame, else it doesn't get displayed
    //SWFMovieClip_nextFrame(movie_clip);

    // Add the movie clip to the main movie
    //buttons_display_item = SWFMovie_add(swfInfo->m, movie_clip);
	//addToDisplayList( buttons_display_item );

    // Set the movie clip to be shown higher 
	// in the display stack than the main movie
    //SWFDisplayItem_setDepth(buttons_display_item, 100);
	
}
Пример #8
0
SWFFillStyle
SWFShape_addSolidFillStyle(SWFShape shape, byte r, byte g, byte b, byte a)
{
	return addFillStyle(shape, newSWFSolidFillStyle(r, g, b, a));
}
Пример #9
0
static VALUE from_gradient(VALUE klass, VALUE _gradient, VALUE style)
{
  SWFGradient gradient;
  Data_Get_Struct(_gradient, struct SWFGradient_s, gradient);

  SWFFillStyle fill_style = newSWFGradientFillStyle(gradient, NUM2INT(style));

  return Data_Wrap_Struct(klass, NULL, destroySWFFillStyle, fill_style);
}

static VALUE new(VALUE klass, VALUE _r, VALUE _g, VALUE _b, VALUE _a)
{
  SWFFillStyle fill_style = newSWFSolidFillStyle(
    NUM2INT(_r),
    NUM2INT(_g),
    NUM2INT(_b),
    NUM2INT(_a)
  );
  return Data_Wrap_Struct(klass, NULL, destroySWFFillStyle, fill_style);
}

static VALUE pointer_id(VALUE self)
{
  SWFFillStyle fs;
  Data_Get_Struct(self, struct SWFFillStyle_s, fs);

  return INT2NUM((int)(fs));
}

VALUE cKedamaSwfFillStyle;
void init_swf_fill_style()