home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume9 / pbmplus / part12 / ppm / ppmdraw.h < prev    next >
C/C++ Source or Header  |  1989-11-26  |  5KB  |  99 lines

  1. /* ppmdraw.h - header file for simple drawing routines in libppm
  2. **
  3. ** Simple, yes, and also fairly slow if the truth be told; but also very
  4. ** flexible and powerful.
  5. **
  6. ** The two basic concepts are the drawproc and clientdata.  All the drawing
  7. ** routines take a drawproc that does the actual drawing.  A drawproc draws
  8. ** a single point, and it looks like this:
  9. */
  10. void ppmd_point_drawproc( /* pixel **pixels, int cols, int rows, pixval maxval, int x, int y, char *clientdata */ );
  11. /*
  12. ** So, you call a drawing routine, e.g. ppmd_line(), and pass it a drawproc;
  13. ** it calls the drawproc for each point it wants to draw.  Why so complicated?
  14. ** Because you can define your own drawprocs to do more interesting things than
  15. ** simply draw the point.  For example, you could make one that calls back into
  16. ** another drawing routine, say ppmd_circle() to draw a circle at each point
  17. ** of a line.
  18. **
  19. ** Slow?  Well sure, we're talking results here, not realtime.  You can do
  20. ** tricks with this arrangement that you couldn't even think of before.
  21. ** Still, to speed things up for the 90% case you can use this:
  22. */
  23. #define PPMD_NULLDRAWPROC (void (*)()) 0
  24. /*
  25. ** Just like ppmd_point_drawproc() it simply draws the point, but it's done
  26. ** inline, and clipping is assumed to be handled at a higher level.
  27. **
  28. ** Now, what about clientdata.  Well, it's an arbitrary pointer, and can
  29. ** mean something different to each different drawproc.  For the above two
  30. ** drawprocs, clientdata should be a pointer to a pixel holding the color
  31. ** to be drawn.  Other drawprocs can use it to point to something else,
  32. ** e.g. some structure to be modified, or they can ignore it.
  33. */
  34.  
  35.  
  36. /* Outline drawing routines.  Lines, splines, circles, etc. */
  37.  
  38. int ppmd_setlinetype( /* int type */ );
  39. #define PPMD_LINETYPE_NORMAL 0
  40. #define PPMD_LINETYPE_NODIAGS 1
  41. /* If you set NODIAGS, all pixels drawn by ppmd_line() will be 4-connected
  42. ** instead of 8-connected; in other words, no diagonals.  This is useful
  43. ** for some applications, for example when you draw many parallel lines
  44. ** and you want them to fit together without gaps.
  45. */
  46.  
  47. int ppmd_setlineclipping( /* int clip */ );
  48. /* Normally, ppmd_line() clips to the edges of the pixmap.  You can use this
  49. ** routine to disable the clipping, for example if you are using a drawproc
  50. ** that wants to do its own clipping.
  51. */
  52.  
  53. void ppmd_line( /* pixel **pixels, int cols, int rows, pixval maxval, int x0, int y0, int x1, int y1, void (*drawprocP)(), char *clientdata */ );
  54. /* Draws a line from (x0, y0) to (x1, y1).
  55. */
  56.  
  57. void ppmd_spline3( /* pixel **pixels, int cols, int rows, pixval maxval, int x0, int y0, int x1, int y1, int x2, int y2, void (*drawprocP)(), char *clientdata */ );
  58. /* Draws a three-point spline from (x0, y0) to (x2, y2), with (x1, y1) as
  59. ** the control point.  All drawing is done via ppmd_line(), so the routines
  60. ** that control it control ppmd_spline3() as well.
  61. */
  62.  
  63. void ppmd_polyspline( /* pixel **pixels, int cols, int rows, pixval maxval, int x0, int y0, int nc, int *xc, int *yc, int x1, int y1, void (*drawprocP)(), char *clientdata */ );
  64. /* Draws a bunch of splines end to end.  (x0, y0) and (x1, y1) are the initial
  65. ** and final points, and the xc and yc are the intermediate control points.
  66. ** nc is the number of these control points.
  67. */
  68.  
  69. void ppmd_circle( /* pixel **pixels, int cols, int rows, pixval maxval, int cx, int cy, int radius, void (*drawprocP)(), char *clientdata */ );
  70. /* Draws a circle centered at (cx, cy) with the specified radius.
  71. */
  72.  
  73.  
  74. /* Simple filling routines.  Ok, so there's only one. */
  75.  
  76. void ppmd_filledrectangle( /* pixel **pixels, int cols, int rows, pixval maxval, int x, int y, int width, int height, void (*drawprocP)(), char *clientdata */ );
  77. /* Fills in the rectangle [x, y, width, height].
  78. */
  79.  
  80.  
  81. /* Arbitrary filling routines.  With these you can fill any outline that
  82. ** you can draw with the outline routines.
  83. */
  84.  
  85. char *ppmd_fill_init( );
  86. /* Returns a blank fillhandle.
  87. */
  88.  
  89. void ppmd_fill_drawproc( /* pixel **pixels, int cols, int rows, pixval maxval, int col, int row, char *clientdata */ );
  90. /* Use this drawproc to trace the outline you want filled.  Be sure to use
  91. ** the fillhandle as the clientdata.
  92. */
  93.  
  94. void ppmd_fill( /* pixel **pixels, int cols, int rows, pixval maxval, char *fillhandle, void (*drawprocP)(), char *clientdata */ );
  95. /* Once you've traced the outline, give the fillhandle to this routine to
  96. ** do the actual drawing.  As usual, it takes a drawproc and clientdata;
  97. ** you could define drawprocs to do stipple fills and such.
  98. */
  99.