Beispiel #1
0
//----------------------------------------------------------------------------------------------------------------------
//protected
void Tracer::trace(int cmd, int param){
    static int offsetRcpt = 0;
    switch (cmd){
        default: // PU:
        penup();
        break;
        case PD:
        pendown();
        break;
        case FW:
        forward( (float) param );
        break;
        case TR:
        //correction déviation droite déterminée de manière empirique
        offsetRcpt += param;
        if (offsetRcpt >= 180 ){
            offsetRcpt = 0;
            param +=2;
        }
        right( (float) param );
        break;    
        case TL:
        left( (float) param );
        break;          
    }
}
Beispiel #2
0
void tree (int len, int level)
{
  if (0 == level) {
    return;
  }
  else {
    setcolor (level);
    forwd (len);
    turnleft (45);
    tree (len * 6 / 10, level - 1);
    turnleft (90);
    tree (len * 3 / 4, level - 1);
    turnleft (45);
    penup ();
    forwd (len);
    pendown ();
  }
}
Beispiel #3
0
/* Draw a character at the current position */
static void _drawc(short int *vp, short int nvecs, double scale, short int width)
{
	register short int nx, ny;	/* New x,y coordinates */
	short int ox, oy;		/* Old x,y coordinates */
	short int i;

	struct TIGvec jvec, *vecp;
	struct TIGvec origin;		/* Origin */

	jvec.Zpos = 0;		/* Do it now and don't do it again */
	origin = ppmap;
	for( ; nvecs--; vp++ ) {
		if( !*vp ) {
			if( width < 256 ) {
				/* sign extension is necessary */
				ox = HIBYTE(*++vp);
				oy = LOBYTE(*vp);
				nx = (double)(ox) * scale;
				ny = (double)(oy) * scale;

				jvec.Xpos = nx;
				jvec.Ypos = ny;

			}
			else {
				if(*(vp + 1) != 0 )
					goto jumpout;	/* Vector bonified */
				vp += 2;	/* This zero, and next */
				jvec.Xpos = nx = (ox = *vp++) * scale;
				jvec.Ypos = ny = (oy = *vp) * scale;

			}

			/* Move back to origin, move out to new position */
			penup();
			--nvecs;	/* Since we have to jump over 0 vector -- the reset marker */
			vecp = TIGdot( &jvec, &ppwrpln );	/* Map into writing plane */
			move2pt( origin.Xpos+vecp->Xpos, origin.Ypos+vecp->Ypos, origin.Zpos+vecp->Zpos );
			pendown();
			continue;
		}
jumpout:
		/* We do it this way to minimize truncation errors */

		if( width < 256 ) {
			/* Sign extension is necessary  */
			ox += HIBYTE(*vp);
			oy += LOBYTE(*vp);
 		}
		else {
			ox += *vp++;
			oy += *vp;
		}

		/* defines evaluation order properly, BJZ */
		nx += ((ox - nx/scale) * scale);
		ny += ((oy - ny/scale) * scale);
		jvec.Xpos = nx;
		jvec.Ypos = ny;

		vecp = TIGdot( &jvec, &ppwrpln );	/* Map into writing plane */
		move2pt( origin.Xpos+vecp->Xpos, origin.Ypos+vecp->Ypos, origin.Zpos+vecp->Zpos );
	}
	penup();
	move2pt(origin.Xpos, origin.Ypos, origin.Zpos);
}