source code for solid/filled arrowhead

P.Romero romero619 at HOTMAIL.COM
Tue Jan 20 12:44:00 EST 2009


In case anyone is interested in having solid/filled arrowheads for 'gxout
vector', here's the source code I came up with:



//modify gagx.c source file

//@ around line 3265

//replace entire gaarrw function, and add/modify the static 'a150'/'a165'
variables beforehand



static gadouble a150 = 150.0*3.141592654/180.0;

static gadouble a165 = 165.0*3.141592654/180.0;

void gaarrw (gadouble x, gadouble y, gadouble ang, gadouble siz, gadouble
asiz) {

gadouble xx,yy;

gadouble xy[8];



  if (siz<0.0001) {

    gxmark (2, x, y, 0.01);

    return;

  }

  gxplot (x,y,3);

  xx = x+siz*cos(ang);

  yy = y+siz*sin(ang);

  gxplot (xx,yy,2);

  if (asiz==0.0) return;

  if (asiz<0.0) asiz = -1.0*asiz*siz;



  //new filled arrowhead

  xy[0]=xx;

  xy[1]=yy;

  xy[2]=xx+asiz*cos(ang+a165);

  xy[3]=yy+asiz*sin(ang+a165);

  xy[4]=xx+asiz*cos(ang-a165);

  xy[5]=yy+asiz*sin(ang-a165);

  xy[6]=xy[0];

  xy[7]=xy[1];

  gxfill(xy,4);



   //original non-filled arrowhead

  //plot arrow head lines

  //first plot one line, then move back to tip, then plot second line

  /*

  gxplot (xx+asiz*cos(ang+a150),yy+asiz*sin(ang+a150),2);

  gxplot (xx,yy,3);

  gxplot (xx+asiz*cos(ang-a150),yy+asiz*sin(ang-a150),2);

  */

}



.I tested this and it seems to work fine.

I changed the arrowhead angle to 165 degrees because the arrowheads seemed
too wide at 150, just my opinion.

I guess ideally this function should have arguments for "isFilled" and
"arrowHeadAngle", to allow the user to select standard/filled arrowhead, and
the angle used to determine the arrowhead's spread.

P.Romero

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090120/95126569/attachment.html 


More information about the gradsusr mailing list