home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GSPAINT.C < prev    next >
C/C++ Source or Header  |  1992-06-12  |  3KB  |  113 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gspaint.c */
  21. /* Painting procedures for GhostScript library */
  22. #include "gx.h"
  23. #include "gpcheck.h"
  24. #include "gserrors.h"
  25. #include "gxfixed.h"
  26. #include "gxmatrix.h"            /* for gs_state */
  27. #include "gspaint.h"
  28. #include "gzpath.h"
  29. #include "gzstate.h"
  30. #include "gzdevice.h"
  31. #include "gzcolor.h"
  32. #include "gxcpath.h"
  33. #include "gxdevmem.h"
  34. #include "gximage.h"
  35.  
  36. /* Erase the page */
  37. int
  38. gs_erasepage(gs_state *pgs)
  39. {    device *pdev = pgs->device;
  40.     gx_device *dev = pdev->info;
  41.     (*dev->procs->fill_rectangle)(dev, 0, 0, dev->width, dev->height, pdev->white);
  42.     gp_check_interrupts();
  43.     return 0;
  44. }
  45.  
  46. /* Fill using the winding number rule */
  47. int
  48. gs_fill(gs_state *pgs)
  49. {    return gs_fill_adjust(pgs, (fixed)0);
  50. }
  51. /* This is a hack, see gx_fill_path and gs_type1_interpret. */
  52. int
  53. gs_fill_adjust(gs_state *pgs, fixed adjust)
  54. {    int code;
  55.     /* If we're inside a charpath, just merge the current path */
  56.     /* into the parent's path. */
  57.     if ( pgs->in_charpath )
  58.         code = gx_path_add_path(pgs->saved->path, pgs->path);
  59.     else
  60.        {    gx_color_load(pgs->dev_color, pgs);
  61.         code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
  62.                     gx_rule_winding_number, adjust);
  63.         if ( !code ) gs_newpath(pgs);
  64.        }
  65.     return code;
  66. }
  67.  
  68. /* Fill using the even/odd rule */
  69. int
  70. gs_eofill(gs_state *pgs)
  71. {    int code;
  72.     /* If we're inside a charpath, just merge the current path */
  73.     /* into the parent's path. */
  74.     if ( pgs->in_charpath )
  75.         code = gx_path_add_path(pgs->saved->path, pgs->path);
  76.     else
  77.        {    gx_color_load(pgs->dev_color, pgs);
  78.         code = gx_fill_path(pgs->path, pgs->dev_color, pgs,
  79.                     gx_rule_even_odd, (fixed)0);
  80.         if ( !code ) gs_newpath(pgs);
  81.        }
  82.     return code;
  83. }
  84.  
  85. /* Stroke the current path */
  86. int
  87. gs_stroke(gs_state *pgs)
  88. {    int code;
  89.     /* If we're inside a charpath, just merge the current path */
  90.     /* into the parent's path. */
  91.     if ( pgs->in_charpath )
  92.         code = gx_path_add_path(pgs->saved->path, pgs->path);
  93.     else
  94.        {    gx_color_load(pgs->dev_color, pgs);
  95.         code = gx_stroke_fill(pgs->path, pgs);
  96.         if ( !code ) gs_newpath(pgs);
  97.        }
  98.     return code;
  99. }
  100.  
  101. /* Compute the stroked outline of the current path */
  102. int
  103. gs_strokepath(gs_state *pgs)
  104. {    gx_path spath;
  105.     int code;
  106.     gx_path_init(&spath, &pgs->memory_procs);
  107.     code = gx_stroke_add(pgs->path, &spath, pgs);
  108.     if ( code < 0 ) return code;
  109.     gx_path_release(pgs->path);
  110.     *pgs->path = spath;
  111.     return 0;
  112. }
  113.