f_closepl.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* For FigPlotter objects, we place all user-defined colors [``color
  16. pseudo-objects''], which must appear first in the .fig file, in a header
  17. for the page.
  18. Note that a Fig file may contain no more than a single page of graphics.
  19. Later pages are simply deallocated by closepl(), even though we go to
  20. som trouble to prepare them. */
  21. #include "sys-defines.h"
  22. #include "extern.h"
  23. bool
  24. _pl_f_end_page (S___(Plotter *_plotter))
  25. {
  26. int i;
  27. const char *units;
  28. plOutbuf *fig_header;
  29. /* prepare Fig header, write it to a plOutbuf */
  30. fig_header = _new_outbuf ();
  31. units = (_plotter->data->page_data->metric ? "Metric" : "Inches");
  32. sprintf (fig_header->point,
  33. "#FIG 3.2\n%s\n%s\n%s\n%s\n%.2f\n%s\n%d\n%d %d\n",
  34. "Portrait", /* portrait mode, not landscape */
  35. "Flush Left", /* justification */
  36. units, /* "Metric" or "Inches" */
  37. _plotter->data->page_data->fig_name, /* paper size */
  38. 100.00, /* export and print magnification */
  39. "Single", /* "Single" or "Multiple" pages */
  40. -2, /* color number for transparent color */
  41. IROUND(FIG_UNITS_PER_INCH), /* Fig units per inch */
  42. 2 /* origin in lower left corner (ignored) */
  43. );
  44. _update_buffer (fig_header);
  45. /* output user-defined colors if any */
  46. for (i = 0; i < _plotter->fig_num_usercolors; i++)
  47. {
  48. sprintf (fig_header->point,
  49. "#COLOR\n%d %d #%06lx\n",
  50. 0, /* color pseudo-object */
  51. FIG_USER_COLOR_MIN + i, /* color num, in xfig's range */
  52. _plotter->fig_usercolors[i] /* 24-bit RGB value */
  53. );
  54. _update_buffer (fig_header);
  55. }
  56. /* place header in the plOutbuf for the page */
  57. _plotter->data->page->header = fig_header;
  58. return true;
  59. }