Exemplo n.º 1
0
void parse_coordinates(void) 
{
	double X=0,Y=0,test=0;
	int getxgety=0;

	while(*token) {
		if(tok_type==NUMBER) {
			if(strchr(token,'+')) {
				test=atof(token);
				++totalcoords;
				// fixme: do this right
				if (getxgety==0) {
					X=test;
					getxgety=1;
				} else {
					Y=test;
					addcoord(X,Y);						
					getxgety=0;
				}	
			} 
			//else printf("+ not found\n");		
		} 
		get_token();	
	}

//	if(getxgety==1) exit(1); // only x coord!
	return;
};
Exemplo n.º 2
0
static void
buildlist(PLINT xp1, PLINT yp1, PLINT xp2, PLINT yp2, PLINT xp3, PLINT yp3,
	  PLINT dinc)
{
    PLINT min_y, max_y;
    PLINT dx, dy, cstep, nstep, ploty, plotx;

    (void) xp3;				/* pmr: make it used */

    dx = xp2 - xp1;
    dy = yp2 - yp1;

    if (dy == 0) {
	if (yp2 > yp3 && ((yp2 % dinc) == 0))
	    addcoord(xp2, yp2);
	return;
    }

    if (dy > 0) {
	cstep = 1;
	min_y = yp1;
	max_y = yp2;
    }
    else {
	cstep = -1;
	min_y = yp2;
	max_y = yp1;
    }

    nstep = (yp3 > yp2 ? 1 : -1);
    if (yp3 == yp2) nstep = 0;

    /* Build coordinate list */

    ploty = (min_y / dinc) * dinc;
    if (ploty < min_y) ploty += dinc;

    for (; ploty <= max_y; ploty += dinc) {
	if (ploty == yp1) continue;
	if (ploty == yp2) {
	    if (cstep == -nstep) continue;
	    if (yp2 == yp3 && yp1 > yp2) continue;
	}
	plotx = xp1 + floor(((double) (ploty - yp1) * dx) / dy + 0.5);
	addcoord(plotx, ploty);
    }
}
Exemplo n.º 3
0
static
void
dopoly(int cmd, Image *dst, Point *pp, int np, int end0, int end1, int radius, Image *src, Point *sp, Drawop op)
{
	uchar *a, *t, *u;
	int i, ox, oy;

	if(np == 0)
		return;
	t = malloc(np*2*3);
	if(t == nil)
		return;
	u = t;
	ox = oy = 0;
	for(i=0; i<np; i++){
		u = addcoord(u, ox, pp[i].x);
		ox = pp[i].x;
		u = addcoord(u, oy, pp[i].y);
		oy = pp[i].y;
	}

	_setdrawop(dst->display, op);

	a = bufimage(dst->display, 1+4+2+4+4+4+4+2*4+(u-t));
	if(a == 0){
		free(t);
		fprint(2, "image poly: %r\n");
		return;
	}
	a[0] = cmd;
	BPLONG(a+1, dst->id);
	BPSHORT(a+5, np-1);
	BPLONG(a+7, end0);
	BPLONG(a+11, end1);
	BPLONG(a+15, radius);
	BPLONG(a+19, src->id);
	BPLONG(a+23, sp->x);
	BPLONG(a+27, sp->y);
	memmove(a+31, t, u-t);
	free(t);
}
Exemplo n.º 4
0
void parse_datahdr(void) 
{
// fixme: quick and dirty...
	int id;
	double X,Y;

	if (phase==0) {		// phase=0, we're at the first LAB section
		if(!*token) return;
		if(tok_type!=NUMBER) return;

		id=atoi(token);

		if (id==-1) {
			phase=1;
			return;
		}

// Let's get ID... 
		get_token();
		if(!*token) return;
		if(tok_type!=NUMBER) return;
		id=atoi(token);
// and X coord...		
		get_token();
		if(!*token) return;
		if(tok_type!=NUMBER) return;
		X=atof(token);
// and Y coord...		
		get_token();
		if(!*token) return;
		if(tok_type!=NUMBER) return;
		Y=atof(token);
// then add them to list...		
		addcoord(id,X,Y);						
	}
	return;
}