Пример #1
0
int dot(int x, int y)
{
    double vx[5], vy[5];

    vx[0] = x;
    vy[0] = y - dotsize;
    vx[1] = x - dotsize;
    vy[1] = y;
    vx[2] = x;
    vy[2] = y + dotsize;
    vx[3] = x + dotsize;
    vy[3] = y;
    vx[4] = x;
    vy[4] = y - dotsize;

    R_polygon_abs(vx, vy, 5);
    /*
       int i;

       for (i = 0; i < dotsize; i++)
       {
       R_move_abs (x-i, y+i-dotsize);
       R_cont_rel (i+i,0);
       R_move_abs (x-i, y+dotsize-i);
       R_cont_rel (i+i,0);
       }
       R_move_abs (x-dotsize, y);
       R_cont_rel (dotsize+dotsize, 0);
     */

    return 0;
}
Пример #2
0
int do_poly(char *buff, FILE * infile)
{
    int num;
    char origcmd[64];
    float xper, yper;
    char *fgets();
    int to_return;

    sscanf(buff, "%s", origcmd);

    num = 0;

    for (;;) {
	if ((to_return = G_getl2(buff, 128, infile)) != 1)
	    break;

	if (2 != sscanf(buff, "%f %f", &xper, &yper)) {

	    if ('#' == buff[0]) {
		G_debug(3, " skipping comment line [%s]", buff);
		continue;
	    }

	    G_debug(3, "coordinate pair not found. ending polygon. [%s]",
		    buff);
	    break;
	}

	if (!mapunits) {
	    if (xper < 0. || yper < 0. || xper > 100. || yper > 100.)
		break;
	}
	check_alloc(num + 1);

	if (mapunits) {
	    xarray[num] = (int)(D_u_to_d_col(xper) + 0.5);
	    yarray[num] = (int)(D_u_to_d_row(yper) + 0.5);
	}
	else {
	    xarray[num] = l + (int)(xper * xincr);
	    yarray[num] = b - (int)(yper * yincr);
	}

	num++;
    }

    if (num) {
	/* this check is here so you can use the "polyline" command 
	   to make an unfilled polygon */
	if (!strcmp(origcmd, "polygon"))
	    R_polygon_abs(xarray, yarray, num);
	else
	    R_polyline_abs(xarray, yarray, num);
    }

    return (to_return);
}
Пример #3
0
int draw_slice(struct Colors *colors, int fill_flag, DCELL fill_color1, DCELL fill_color2, int txt_color, double cx, double cy, double r,	/* in normalized coords. */
	       double a1, double a2	/* in degrees */
    )
{
    int tt, tb, tr, tl;
    int height, width;
    int yoffset, xoffset;
    int x[1000], y[1000];
    int lx, ly;
    int i = 1;
    char txt[512];
    double arc, arc_incr = 0.01;
    DCELL fill_color;

    D_get_screen_window(&tt, &tb, &tl, &tr);

    height = tb - tt;
    width = tr - tl;
    yoffset = tb;
    xoffset = tl;

    while (a2 / arc_incr > 998)
	arc_incr *= 2;

    x[0] = (int)((double)xoffset + cx * (double)width);
    y[0] = (int)((double)yoffset - cy * (double)height);

    arc = a1;
    if (fill_flag && fill_color1 != fill_color2) {
	i = 1;
	while (arc <= (a1 + a2)) {
	    fill_color = fill_color1 + (arc - a1) *
		(fill_color2 - fill_color1) / a2;
	    x[i] = x[0] + r * (width) * cos(arc / 57.296);
	    y[i] = y[0] - r * (height) * sin(arc / 57.296);
	    if (i == 2) {
		D_d_color(fill_color, colors);
		R_polygon_abs(x + i - 2, y + i - 2, 3);
		x[i - 1] = x[i];
		y[i - 1] = y[i];
	    }
	    else
		i++;
	    arc = arc + arc_incr;
	}
    }
    else {
	i = 1;
	while (arc <= (a1 + a2)) {
	    x[i] = x[0] + r * (width) * cos(arc / 57.296);
	    y[i] = y[0] - r * (height) * sin(arc / 57.296);
	    i++;
	    arc = arc + arc_incr;
	}

	if (!fill_flag) {
	    R_standard_color(txt_color);
	    R_polyline_abs(x, y, i);
	}
	else {
	    D_d_color(fill_color1, colors);
	    R_polygon_abs(x, y, i);
	}
    }

    if (a2 > 15.0) {
	/* draw a label */
	arc = a1 + a2 / 2;
	sprintf(txt, "%2.0f%s", (double)(a2 / (double)360.0) * (double)100.0,
		percent);
	R_get_text_box(txt, &tt, &tb, &tl, &tr);
	lx = x[0] + (r + 0.03) * (width) * cos(arc / 57.296) - (tr - tl) / 2;
	ly = y[0] - (r + 0.03) * (height) * sin(arc / 57.296) + (tb - tt) / 2;
	R_move_abs(lx, ly);
	R_standard_color(txt_color);
	R_text(txt);
    }

    return 0;
}