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); }
static void SWF_SetLineStyle(SWFShape shape, const pGEcontext plotParams, swfDevDesc *swfInfo ){ byte red = R_RED(plotParams->col); byte green = R_GREEN(plotParams->col); byte blue = R_BLUE(plotParams->col); byte alpha = R_ALPHA(plotParams->col); if( swfInfo->debug == TRUE ){ fprintf(swfInfo->logFile,"\tLineStyle: 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); } //FIXME: Honor all the line parameters such as //lty, lend, ljoin SWFShape_setLine(shape, (unsigned short) plotParams->lwd, red, green, blue, alpha); /* does not play nicely with setRightFill SWFShape_setLine2Filled(shape, (unsigned short) plotParams->lwd, newSWFSolidFillStyle( red, green, blue, alpha ), SWF_LINESTYLE_CAP_ROUND, plotParams->lmitre); */ }
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); }
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; }
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; }
EXPORT BOOL WINAPI s_setLine(HSPEXINFO *hei, int p2, int p3, int p4) { int width; byte r, g, b, a; lstrcpy(funcname, "s_setLine"); width = hei->HspFunc_prm_getdi(0); r = (byte)hei->HspFunc_prm_getdi(0); g = (byte)hei->HspFunc_prm_getdi(0); b = (byte)hei->HspFunc_prm_getdi(0); a = (byte)hei->HspFunc_prm_getdi(0xff); SWFShape_setLine(mhsp_shape, width, r, g, b, a); return 0; }
static VALUE set_line(VALUE self, VALUE w, VALUE r, VALUE g, VALUE b, VALUE a) { SWFShape shape; Data_Get_Struct(self, struct SWFShape_s, shape); SWFShape_setLine(shape, NUM2DBL(w), NUM2DBL(r), NUM2DBL(g), NUM2DBL(b), NUM2DBL(a) ); return self; }
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; }
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; }
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); }
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); }
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); }