gint change_noise_seed (GtkWidget *entry, gpointer img_pointer) { img_dialog_struct *img = (img_dialog_struct *) img_pointer; // printf("COMPUTE_NOISE_PREVIEW\n"); img->voronoi->noise_opt->seed =(gint) atoi((char *) gtk_entry_get_text(GTK_ENTRY(entry))); calc_subdiv1 (img->voronoi_dialog->preview_buf, NOISE_PREVIEW_SIZE, NOISE_PREVIEW_SIZE, img->voronoi->noise_opt); draw_area (img->voronoi_dialog->noise_preview); return FALSE; }
/** * move_card: * @data: #card_move structure that contains the card movement information * * Move the given card towards its destination by the given * movement step * * The card movement structure contains the information about what card to move, * the movement destination and the movement step. * * Returns: %FALSE if the card movement is finished, otherwise %TRUE */ gboolean move_card(gpointer data) { card_move *cm = (card_move *) data; card *ptr = cm->mcard; gint step; gint x_move = cm->x_move; gint y_move = cm->y_move; gint dx = ptr->dim.x - cm->dest_x; gint dy = ptr->dim.y - cm->dest_y; /* adjust x coordinate */ if (ABS(dx) < x_move) ptr->dim.x = cm->dest_x; else { step = (dx > 0) ? -x_move : x_move; ptr->dim.x += step; } /* adjust y coordinate */ if (ABS(dy) < y_move) ptr->dim.y = cm->dest_y; else { step = (dy > 0) ? -y_move : y_move; ptr->dim.y += step; } /* check for finished movement */ if (ptr->dim.x == cm->dest_x && ptr->dim.y == cm->dest_y) { ptr->status = CS_AVAILABLE; draw_area(); g_free(cm); return FALSE; } draw_area(); return TRUE; }
static gint area_configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer data) { view_struct *vs; vs = (view_struct *) data; // We initialize the drawable: // printf("Area_configure_event\n"); gdk_draw_rectangle(vs->area->window, vs->area->style->black_gc,TRUE, 0, 0, vs->area->allocation.width, vs->area->allocation.height); draw_area (vs); return TRUE; }
/** * load_game: * @filename: File name of the saved game * * Try to load the game state saved in the given file name * and update the game state appropriately. */ void load_game(gchar *filename) { if (read_state_from_file(filename)) { gskat.state = PLAYING; update_interface(); calc_card_positions(); draw_area(); play_stich(); /* activate the quicksave, bugreport and gamesave menu items */ gtk_widget_set_sensitive(get_widget("mi_quicksave"), TRUE); gtk_widget_set_sensitive(get_widget("mi_bugreport"), TRUE); gtk_widget_set_sensitive(get_widget("mi_gamesave"), TRUE); } }
/* This is called upon mouseUp and checks what action is to take * The DeviceVector position is passed with constrained values that are between [-1,+1] */ void SelectObserver::testSelect(DeviceVector position) { // Get the MouseEvents class from the EventManager IMouseEvents& mouseEvents = GlobalEventManager().MouseEvents(); // Obtain the current modifier status (eManipulator, etc.) SelectionSystem::EModifier modifier = getModifier(); // Determine, if we have a face operation // Retrieve the according ObserverEvent for the GdkEventButton ui::ObserverEvent observerEvent = mouseEvents.getObserverEvent(*_wxEvent); bool isFaceOperation = (observerEvent == ui::obsToggleFace || observerEvent == ui::obsReplaceFace); // If the user pressed some of the modifiers (Shift, Alt, Ctrl) the mode is NOT eManipulator // so the if clause is true if there are some modifiers active if (modifier != SelectionSystem::eManipulator) { // Get the distance of the mouse pointer from the starting point DeviceVector delta(position - _start); // If the mouse pointer has moved more than <epsilon>, this is considered a drag operation if (fabs(delta.x()) > _epsilon.x() && fabs(delta.y()) > _epsilon.y()) { // This is a drag operation with a modifier held DeviceVector delta(position - _start); // << superfluous? // Call the selectArea command that does the actual selecting GlobalSelectionSystem().SelectArea(*_view, &_start[0], &delta[0], modifier, isFaceOperation); } else { // greebo: This is a click operation with a modifier held // If Alt-Shift (eReplace) is held, and we already replaced a selection, switch to cycle mode // so eReplace is only active during the first click with Alt-Shift if (modifier == SelectionSystem::eReplace && _unmovedReplaces++ > 0) { modifier = SelectionSystem::eCycle; } // Call the selectPoint command in RadiantSelectionSystem that does the actual selecting GlobalSelectionSystem().SelectPoint(*_view, &position[0], &_epsilon[0], modifier, isFaceOperation); } } // Reset the mouse position to zero, this mouse operation is finished so far _start = _current = DeviceVector(0.0f, 0.0f); draw_area(); }
void StyleBorderImageRenderer::render() { if (!style.computed_value("border-image-source").is_url()) return; Image image = Image::resource(canvas, style.computed_value("border-image-source").text(), UIThread::get_resources()); if (image) { int slice_left = get_left_slice_value(image.get_width()); int slice_right = get_right_slice_value(image.get_width()); int slice_top = get_top_slice_value(image.get_height()); int slice_bottom = get_bottom_slice_value(image.get_height()); bool fill_center = style.computed_value("border-image-slice-center").is_keyword("fill"); Rectf border_image_area = get_border_image_area(); float grid_left = get_left_grid(border_image_area.get_width(), slice_left); float grid_right = get_right_grid(border_image_area.get_width(), slice_right); float grid_top = get_top_grid(border_image_area.get_height(), slice_top); float grid_bottom = get_bottom_grid(border_image_area.get_height(), slice_bottom); float x[4] = { border_image_area.left, border_image_area.left + grid_left, border_image_area.right - grid_right, border_image_area.right }; float y[4] = { border_image_area.top, border_image_area.top + grid_top, border_image_area.bottom - grid_bottom, border_image_area.bottom }; int sx[4] = { 0, slice_left, (int)image.get_width() - slice_right, (int)image.get_width() }; int sy[4] = { 0, slice_top, (int)image.get_height() - slice_bottom, (int)image.get_height() }; StyleGetValue repeat_x = style.computed_value("border-image-repeat-x"); StyleGetValue repeat_y = style.computed_value("border-image-repeat-y"); for (int yy = 0; yy < 3; yy++) { for (int xx = 0; xx < 3; xx++) { if ((xx != 1 && yy != 1) || fill_center) draw_area(image, x[xx], y[yy], x[xx + 1] - x[xx], y[yy + 1] - y[yy], sx[xx], sy[yy], sx[xx + 1] - sx[xx], sy[yy + 1] - sy[yy], repeat_x, repeat_y); } } } }
// onMouseMove: store the current position, and call the area draw update void SelectObserver::mouseMoved(DeviceVector position) { _current = device_constrained(position); draw_area(); }
void ram(void) { getInputWaitRelease(); reset_area(); random_area(life,1,1,RESX,RESY,40); static int nickx=2,nicky=10; signed char movy=1; static int nickwidth,nickheight; static int nickoff=10; static char delaytime=10; static char speedmode=0; static char LCDSHIFTX_EVERY_N=2; static char LCDSHIFTY_EVERY_N=2; static char ITER_EVERY_N=1; lcdClear(); setExtFont(GLOBAL(nickfont)); nickwidth=DoString(nickx,nicky,GLOBAL(nickname)); if(nickwidth<50)nickoff=30; nickheight=getFontHeight(); char stepmode=0; while (1) { draw_area(); // xor life pattern over display content lcdDisplay(); lcdClear(); // draw_area(); // xor life pattern again to restore original display content // Old shift code. Can't handle longer Nicks... // if(iter%LCDSHIFT_EVERY_N==0) lcdShift(1,-2,1); // if(iter%LCDSHIFT_EVERY_N==0) { nickx=(nickx+1)%100-nickwidth; nicky=(nicky+1)%50;} if(iter%LCDSHIFTX_EVERY_N==0) { nickx--; if(nickx<(-1*nickwidth-nickoff))nickx=0; } if(iter%LCDSHIFTY_EVERY_N==0) { nicky+=movy; if(nicky<1 || nicky>RESY-nickheight) movy*=-1; } DoString(nickx,nicky,GLOBAL(nickname)); DoString(nickx+nickwidth+nickoff,nicky,GLOBAL(nickname)); if(nickwidth<RESX) DoString(nickx+2*(nickwidth+nickoff),nicky,GLOBAL(nickname)); char key=stepmode?getInputWait():getInputRaw(); stepmode=0; switch(key) { case BTN_ENTER: return; case BTN_RIGHT: getInputWaitRelease(); speedmode=(speedmode+1)%7; delaytime=15; switch(speedmode) { case 0: ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break; case 1: ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=2; LCDSHIFTY_EVERY_N=2; break; case 2: ITER_EVERY_N=1; LCDSHIFTX_EVERY_N=4; LCDSHIFTY_EVERY_N=4; break; case 3: ITER_EVERY_N=2; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break; case 4: ITER_EVERY_N=4; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break; case 5: ITER_EVERY_N=8; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break; case 6: delaytime=5; ITER_EVERY_N=8; LCDSHIFTX_EVERY_N=1; LCDSHIFTY_EVERY_N=1; break; } break; case BTN_DOWN: stepmode=1; getInputWaitRelease(); break; case BTN_LEFT: pattern=(pattern+1)%PATTERNCOUNT; case BTN_UP: stepmode=1; reset_area(); getInputWaitRelease(); break; } delayms_queue_plus(delaytime,0); #ifdef SIMULATOR fprintf(stderr,"Iteration %d - x %d, y %d \n",iter,nickx,nicky); #endif if(iter%ITER_EVERY_N==0) calc_area(); else ++iter; } return; }
int main() { json_t *root; json_error_t error; root = json_load_file("../test.json", 0, &error); if(root == 0){ printf("ERRO AO LER ARQUIVO, linha %d!\n", error.line); return error.line; } const char * fileName = JSON_getString(root, "fileName"); printf("O nome do arquivo é: %s\n", fileName); const char * format = JSON_getString(root, "format"); if(strcmp(format, "png") != 0 && strcmp(format, "pdf") != 0 ){ printf("Formato: o formato %s não é suportado!\n", format); return 0; } printf("O formato é: %s\n", JSON_getString(root, "format")); const char * name = JSON_getString(root, "name"); printf("O titulo do grafico é: %s\n", name); int width = JSON_getInt(root, "width"); if(width < 200 || width > 1000){ printf("Width: medida não suportada!\n"); return 0; } printf("Width: %d\n", width); int height = JSON_getInt(root, "height"); if(height < 200 || height > 1000){ printf("Height: medida não suportada!\n"); return 0; } printf("Height: %d\n", height); int type = JSON_getInt(root, "type"); printf("Type: %d\n", type); double aux; //aux = height/width; if(height>width) aux = (width/200); else aux = (height/200); cairo_surface_t *surface; if(strcmp(format, "png") == 0){ surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); } else{ surface = cairo_pdf_surface_create(fileName, width, height); } cairo_t *context = cairo_create(surface); cairo_set_source_rgba(context, 1, 1, 1, 1); cairo_rectangle(context, 0, 0, width, height); cairo_fill(context); Color pointColor = JSON_getColor(root); Point *points = JSON_getPoints(root); if(type == 0 || type == 1) create_point(context, points, width, height, type, aux, pointColor); if (type==2) { draw_area(context, points, width, height, aux, pointColor); create_point(context, points, width, height, type, aux, pointColor); } draw_line(context, points, width, height, type, aux, pointColor); write_text(context, name, width, height, aux, pointColor); if(strcmp(JSON_getString(root, "format"), "png") == 0) cairo_surface_write_to_png(surface, fileName); else cairo_show_page(context); cairo_destroy(context); cairo_surface_destroy(surface); return 0; }
/*** GENERATE ACTION TO REDRAW AN AREA OF A SPECIFIED WIDGET ***/ static void draw_widgetarea(WIDGET *cw, int rx1, int ry1, int rx2, int ry2) { draw_area(cw, rx1, ry1, rx2, ry2); }
/*** GENERATE ACTION TO REDRAW A SPECIFIED WIDGET ***/ static void draw_widget(WIDGET *cw) { draw_area(cw, 0, 0, cw->wd->w - 1, cw->wd->h - 1); }
/*! \brief Render vector features into list \param Map pointer to Map_info structure \param box bounding box of region to be rendered \param draw_flag types of objects to be rendered (see vedit.h) \param center_easing, center_northing, map_width, map_height, map_res values used for conversion en->xy \return pointer to robject_list structure */ struct robject_list *Vedit_render_map(struct Map_info *Map, struct bound_box *box, int draw_flag, double center_easting, double center_northing, int map_width, int map_height, double map_res) { int i, nfeat, fid; struct ilist *list; struct robject_list *list_obj; struct robject *robj; /* define region */ region.center_easting = center_easting; region.center_northing = center_northing; region.map_width = map_width; region.map_height = map_height; region.map_res = map_res; region.map_west = center_easting - (map_width / 2.) * map_res; region.map_north = center_northing + (map_height / 2.) * map_res; list = Vect_new_list(); list_obj = NULL; state.nitems_alloc = 1000; list_obj = (struct robject_list *)G_malloc(sizeof(struct robject_list)); list_obj->nitems = 0; list_obj->item = (struct robject **)G_malloc(state.nitems_alloc * sizeof(struct robject *)); /* area */ if (draw_flag & DRAW_AREA) { nfeat = Vect_select_areas_by_box(Map, box, list); for (i = 0; i < nfeat; i++) { fid = list->value[i]; draw_area(Map, fid, list_obj); } } /* draw lines inside of current display region */ nfeat = Vect_select_lines_by_box(Map, box, GV_POINTS | GV_LINES, /* fixme */ list); G_debug(1, "Vedit_render_map(): region: w=%f, e=%f, s=%f, n=%f nlines=%d", box->W, box->E, box->S, box->N, nfeat); /* features */ for (i = 0; i < list->n_values; i++) { fid = list->value[i]; robj = draw_line(Map, fid, draw_flag); if (!robj) continue; list_append(list_obj, robj); if (state.type & GV_LINES) { /* vertices */ if (draw_flag & DRAW_VERTEX) { robj = draw_line_vertices(); robj->fid = fid; if (robj) list_append(list_obj, robj); } /* nodes */ if (draw_flag & (DRAW_NODEONE | DRAW_NODETWO)) { draw_line_nodes(Map, fid, draw_flag, list_obj); } /* direction */ if (draw_flag & DRAW_DIRECTION) { draw_line_dir(list_obj, fid); } } } list_obj->item = (struct robject **)G_realloc(list_obj->item, list_obj->nitems * sizeof(struct robject *)); Vect_destroy_list(list); return list_obj; }
void draw_area_callb (GtkWidget *wdg, gpointer view_struct_ptr) { // Convenience function if (view_struct_ptr) draw_area((view_struct *) view_struct_ptr); }