home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 029.lha / BlitLab / render.c < prev    next >
C/C++ Source or Header  |  1987-04-02  |  2KB  |  81 lines

  1. /*
  2.  *   This file handles the graphics primitives for BlitLab.
  3.  */
  4. #include "structures.h"
  5. /*
  6.  *   External variables we use.
  7.  */
  8. extern struct RastPort *myrp ;
  9. /*
  10.  *   color sets the current foreground color to the appropriate value.
  11.  */
  12. color(c)
  13. int c ;
  14. {
  15.    SetAPen(myrp, (long)c) ;
  16.    SetDrMd(myrp, (long)JAM1) ;
  17. }
  18. /*
  19.  *   This routine draws a horizontal or vertical line.
  20.  */
  21. line(x1, y1, x2, y2)
  22. int x1, y1, x2, y2 ;
  23. {
  24.    int t ;
  25.    if (x1 > x2) {
  26.       t = x1 ;
  27.       x1 = x2 ;
  28.       x2 = t ;
  29.    }
  30.    if (y1 > y2) {
  31.       t = y1 ;
  32.       y1 = y2 ;
  33.       y2 = t ;
  34.    }
  35.    if (x1 != x2 && y1 != y2)
  36.       error("! can only draw h/v lines currently") ;
  37.    RectFill(myrp, (long)x1, (long)y1, (long)x2, (long)y2) ;
  38. }
  39. /*
  40.  *   This routine draws a box.
  41.  */
  42. box(x1, y1, xsize, ysize)
  43. int x1, y1, xsize, ysize ;
  44. {
  45.    xsize = x1 + xsize - 1 ;
  46.    ysize = y1 + ysize - 1 ;
  47.    line(x1, y1, xsize, y1) ;
  48.    line(xsize, y1, xsize, ysize) ;
  49.    line(xsize, ysize, x1, ysize) ;
  50.    line(x1, ysize, x1, y1) ;
  51. }
  52. /*
  53.  *   This routine draws a filled box.
  54.  */
  55. fbox(x1, y1, xsize, ysize)
  56. int x1, y1, xsize, ysize ;
  57. {
  58.    RectFill(myrp, (long)x1, (long)y1, (long)(x1 + xsize - 1),
  59.       (long)(y1 + ysize - 1)) ;
  60. }
  61. /*
  62.  *   This routine draws a text string at a particular location.  It is
  63.  *   somewhat crude; we build an IntuiText structure, and tell it to
  64.  *   draw it.
  65.  */
  66. static struct IntuiText dmy = {
  67.    WHITE, BLUE,
  68.    JAM2,
  69.    0, 0,
  70.    NULL,
  71.    NULL,
  72.    NULL
  73. } ;
  74. drawtext(x, y, s)
  75. int x, y ;
  76. char *s ;
  77. {
  78.    dmy.IText = (UBYTE *)s ;
  79.    PrintIText(myrp, &dmy, (long)(x), (long)(y)) ;
  80. }
  81.