textbox.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Function: text_box_path
  2. **
  3. ** Author: Paul W. Carlson March 1992
  4. */
  5. #include "ps_info.h"
  6. #define LEFT 0
  7. #define RIGHT 1
  8. #define LOWER 0
  9. #define UPPER 1
  10. #define CENTER 2
  11. /* font name, size, and color must be set first, outside text_box_path()
  12. * because text_box_path() is called repeatedly with identical
  13. * font name, size, and color */
  14. int
  15. text_box_path(double x, double y, int xref, int yref, char *text,
  16. float rotate)
  17. {
  18. /* get relative box coordinates */
  19. fprintf(PS.fp, "ZB (%s) PB\n", text);
  20. /* set box x coordinate */
  21. fprintf(PS.fp, "%.2f ", x);
  22. /* set box y coordinate */
  23. fprintf(PS.fp, " %.2f ", y);
  24. fprintf(PS.fp, "translate %.2f rotate ", rotate);
  25. fprintf(PS.fp, " 0 ");
  26. switch (xref) {
  27. case LEFT:
  28. fprintf(PS.fp, "LTX");
  29. break;
  30. case RIGHT:
  31. fprintf(PS.fp, "RTX");
  32. break;
  33. case CENTER:
  34. default:
  35. fprintf(PS.fp, "CTX");
  36. break;
  37. }
  38. fprintf(PS.fp, " 0 ");
  39. switch (yref) {
  40. case UPPER:
  41. fprintf(PS.fp, "UTY");
  42. break;
  43. case LOWER:
  44. fprintf(PS.fp, "LTY");
  45. break;
  46. case CENTER:
  47. default:
  48. fprintf(PS.fp, "CTY");
  49. break;
  50. }
  51. fprintf(PS.fp, " TR TB\n");
  52. return 0;
  53. }