home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / src / plptex.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  1.3 KB  |  45 lines

  1. /* Prints out "text" at world cooordinate (x,y). The text may be       */
  2. /* at any angle "angle" relative to the horizontal. The parameter      */
  3. /* "just" adjusts the horizontal justification of the string:          */
  4. /*   just = 0.0 => left hand edge of string is at (x,y)                */
  5. /*   just = 1.0 => right hand edge of string is at (x,y)               */
  6. /*   just = 0.5 => centre of string is at (x,y) etc.                   */
  7. /* N.B. Centreline of the string passes through (x,y)                  */
  8.  
  9. #include "plplot.h"
  10. #include <math.h>
  11.  
  12. void plptex(x,y,dx,dy,just,text)
  13. PLFLT x,y,dx,dy,just;
  14. char *text;
  15. {
  16.       PLINT refx, refy;
  17.       PLFLT shift, cc, ss;
  18.       PLFLT xform[4],diag;
  19.       PLFLT xscl, xoff, yscl, yoff;
  20.       PLINT level;
  21.  
  22.       glev(&level);
  23.       if (level < 3) plexit("Please set up window before calling plptex.");
  24.  
  25.       gwm(&xscl,&xoff,&yscl,&yoff);
  26.       cc = xscl * dx;
  27.       ss = yscl * dy;
  28.       diag = sqrt(cc*cc + ss*ss);
  29.       cc = cc/diag;
  30.       ss = ss/diag;
  31.  
  32.       gmp(&xscl,&xoff,&yscl,&yoff);
  33.       shift = 0.0;
  34.  
  35.       xform[0] = cc;
  36.       xform[1] = -ss;
  37.       xform[2] = ss;
  38.       xform[3] = cc;
  39.  
  40.       if (just != 0.0) shift = plstrl(text) * just;
  41.       refx = wcpcx(x) - shift * cc * xscl;
  42.       refy = wcpcy(y) - shift * ss * yscl;
  43.       plstr(0,xform,refx,refy,text);
  44. }
  45.