home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Atlanta_1990 / Atlanta-Devcon.1 / Libraries / Intuition / CustGad / ellipse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  1.8 KB  |  77 lines

  1. /* ellipse.c -- create ellipse image    */
  2.  
  3. /*
  4. Copyright (c) 1989 Commodore-Amiga, Inc.
  5.  
  6. Executables based on this information may be used in software
  7. for Commodore Amiga computers. All other rights reserved.
  8. This information is provided "as is"; no warranties are made.
  9. All use is at your own risk, and no liability or responsibility
  10. is assumed.
  11. */
  12.  
  13. #include "sysall.h"
  14.  
  15. struct Image    *CreateImage();
  16. struct RastPort    *CreateImageRPort();
  17.  
  18. #define D(x)    ;
  19.  
  20. /*
  21.  * dispose with DeleteImage()
  22.  */
  23. struct Image    *
  24. CreateEllipseImage( width, height, depth, apen, bpen, hthick, vthick )
  25. {
  26.     struct Image    *im;
  27.     struct RastPort    *rp;
  28.     WORD        centerx, centery;
  29.  
  30.     D( printf("CEI: w %d h %d\n", width, height ) );
  31.  
  32.     if ( im = CreateImage( width, height, depth ) )
  33.     {
  34.     D( printf("CEI: im %lx, next at %lx\n", im, im->NextImage ));
  35.         if ( rp = CreateImageRPort( im ) )
  36.     {
  37.         D( printf("CEI: rastport: %lx\n", rp ) );
  38.         centerx = (width - 1) / 2;
  39.         centery = (height - 1) / 2;
  40.         D( printf("cx %d cy %d\n", centerx, centery ) );
  41.  
  42.         /* work around bug with area ellipse    */
  43.         clearWords( rp->AreaInfo->FlagTbl,  5 );
  44.  
  45.         D( printf("cei: doing fine\n") );
  46.  
  47.         /* larger ellipse in border color    */
  48.         SetAPen( rp, (long) bpen );
  49.         AreaEllipse( rp, (long) centerx, (long) centery,
  50.             (long) centerx, (long) centery );
  51.         AreaEnd( rp );
  52.  
  53.         D( printf("cei: still doing fine\n") );
  54.  
  55.         SetAPen( rp, (long) apen );
  56.         AreaEllipse( rp, (long) centerx, (long) centery,
  57.             (long) centerx - vthick, (long) centery - hthick );
  58.         AreaEnd( rp );
  59.  
  60.         D( printf("cei: 3 still doing fine\n") );
  61.  
  62.         DeleteImageRPort( rp );
  63.  
  64.         D( printf("cei: 4 still doing fine\n") );
  65.     }
  66.     else 
  67.     {
  68.         DeleteImage( im );
  69.         im = NULL;
  70.     }
  71.     }
  72.  
  73.     D( printf("CEI: returning: %lx\n", im ) );
  74.  
  75.     return ( im );
  76. }
  77.