Programming and Graphics

(Kiana) #1

216 Introduction to C++ Programming and Graphics


float ysize = 0.02*yrange;

// move to the point:

move2(x, y);

if (marker==1)
circle (x,y,0.005*xrange) ; // circle

else if(marker==2) // triangle
{
rmove2 (0.0,0.5*ysize);
rdraw2 (-0.4*xsize,-0.75*ysize);
rdraw2 (0.8*xsize,0.0);
rdraw2 (-0.4*xsize,0.75*ysize);
rmove2 (0.0,-0.5*ysize);
}

else if(marker==4) // square
{
rmove2 (0.25*xsize,0.25*ysize);
rdraw2 (-0.5*xsize,0.0);
rdraw2 (0.0, -0.5*ysize);
rdraw2 (0.5*xsize,0.0);
rdraw2 (0.0, 0.5*ysize);
rmove2 (-0.25*xsize,-0.25*ysize);
}

else if(marker==5)
{
rmove2 (0.0,0.5*ysize);
rdraw2 (-0.5*xsize,-0.5*ysize);
rdraw2 (0.5*xsize,-0.5*ysize);
rdraw2 (0.5*xsize,0.5*ysize);
rdraw2 (-0.5*xsize,0.5*ysize);
rmove2 (0.0,-0.5*ysize);
}

else if(marker==6)
circle (x,y,0.00001*xrange);
}

Note that the “move to”(move2) and “draw to” (draw2)Voglefunctions have
been used to move the pen lifted up or pressed down.


Function drawline2d


The implementation of the line drawing functiondrawline2dis:
Free download pdf