void rubbercircle(List thelist, int color) { int x1, x2, y1, y2; int radius; int x3, y3; Circle_Type circledata; while (!(mouse_b & 2)) { if (mouse_b & 1) { x3 = x1 = mouse_x; y3 = y1 = mouse_y; scare_mouse(); /* draw circle while waiting for mouse release */ while (mouse_b & 1) { x2 = mouse_x; y2 = mouse_y; if (x2 != x3 || y2 != y3) { rrestore(screen);//first time through ii=0 radius = calc_radius(x1, y1, x2, y2); /* save/draw/wait/restore */ do_circle(screen, x1, y1, radius, color, rsave); x3 = x2; y3 = y2; } } rrestore(screen); x2 = mouse_x; y2 = mouse_y; radius = calc_radius(x1, y1, x2, y2); circlebres(screen, x1, y1, radius, color); circledata.p1.x = x1; circledata.p1.y = y1; circledata.radius = radius; circledata.color = color; circledata.filled = FALSE; circledata.fill_color = 0; circledata.width = 1; AddCircle(thelist, circledata); unscare_mouse(); } } //end while }
static void d_draw_circle (GfigObject *obj, cairo_t *cr) { DobjPoints *center_pnt; DobjPoints *edge_pnt; gint radius; center_pnt = obj->points; if (!center_pnt) return; /* End-of-line */ draw_sqr (¢er_pnt->pnt, obj == gfig_context->selected_obj, cr); edge_pnt = center_pnt->next; if (!edge_pnt) return; radius = calc_radius (¢er_pnt->pnt, &edge_pnt->pnt); if (obj_creating == obj) draw_circle (&edge_pnt->pnt, TRUE, cr); else draw_sqr (&edge_pnt->pnt, obj == gfig_context->selected_obj, cr); gfig_draw_arc (center_pnt->pnt.x, center_pnt->pnt.y, radius, radius, 0, 360, cr); }
void process_tree(void) { float rlast_mm, //rmpeak, mvir_acc, rvir_acc, ratio, rlast_majm, rlast_millim; int64_t i; struct halo *h; for (i=0; i<all_halos.num_halos; i++) { h = &(all_halos.halos[i]); if (h->pid < 0) continue; calc_last_minor_merger(h); if (!h->parent) continue; rlast_mm = calc_radius(h->last_mm_halo, h->parent); rlast_majm = calc_radius(h->last_majm_halo, h->parent); rlast_millim = calc_radius(h->last_millim_halo, h->parent); //rmpeak = calc_radius(h->mpeak_halo, h->parent); calc_host_mvir_rvir(h->acc_halo, h->parent, &mvir_acc, &rvir_acc); ratio = (rvir_acc > 0) ? (rlast_mm / rvir_acc) : 0.0; printf("%.5f %"PRId64" %.3e %.4f %.3e %.2f %.3e %.2f %f %f %f %"PRId64" %.3f %.3f %.4f %.4f %.4f %.4f\n", h->scale, h->id, mvir_acc, rvir_acc, h->mvir, h->vmax, h->last_mm_halo->mvir, h->last_mm_halo->vmax, rlast_mm, ratio, h->acc_halo->vmax, (1-h->sub_ok), rlast_majm, rlast_millim, h->acc_halo->scale, h->last_mm_halo->scale, h->last_majm_halo->scale, h->last_millim_halo->scale); } }
static void d_paint_circle (GfigObject *obj) { DobjPoints *center_pnt; DobjPoints *edge_pnt; gint radius; gdouble dpnts[4]; g_assert (obj != NULL); center_pnt = obj->points; if (!center_pnt) return; /* End-of-line */ edge_pnt = center_pnt->next; if (!edge_pnt) { g_error ("Internal error - circle no edge pnt"); } radius = calc_radius (¢er_pnt->pnt, &edge_pnt->pnt); dpnts[0] = (gdouble) center_pnt->pnt.x - radius; dpnts[1] = (gdouble) center_pnt->pnt.y - radius; dpnts[3] = dpnts[2] = (gdouble) radius * 2; /* Scale before drawing */ if (selvals.scaletoimage) scale_to_original_xy (&dpnts[0], 2); else scale_to_xy (&dpnts[0], 2); if (gfig_context_get_current_style ()->fill_type != FILL_NONE) { gimp_context_push (); gimp_context_set_antialias (selopt.antia); gimp_context_set_feather (selopt.feather); gimp_context_set_feather_radius (selopt.feather_radius, selopt.feather_radius); gimp_image_select_ellipse (gfig_context->image_id, selopt.type, dpnts[0], dpnts[1], dpnts[2], dpnts[3]); gimp_context_pop (); paint_layer_fill (center_pnt->pnt.x - radius, center_pnt->pnt.y - radius, center_pnt->pnt.x + radius, center_pnt->pnt.y + radius); gimp_selection_none (gfig_context->image_id); } /* Drawing a circle may be harder than stroking a circular selection, * but we have to do it or we will not be able to draw outside of the * layer. */ if (obj->style.paint_type == PAINT_BRUSH_TYPE) { const gdouble r = dpnts[2] / 2; const gdouble cx = dpnts[0] + r, cy = dpnts[1] + r; gdouble line_pnts[362]; gdouble angle = 0; gint i = 0; while (i < 362) { static const gdouble step = 2 * G_PI / 180; line_pnts[i++] = cx + r * cos (angle); line_pnts[i++] = cy + r * sin (angle); angle += step; } gfig_paint (selvals.brshtype, gfig_context->drawable_id, i, line_pnts); } }