home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / cpp / graphics / Conics.sit.hqx / Conics / Sources / graphics.cpp < prev    next >
Text File  |  1996-11-08  |  934b  |  46 lines

  1. //Copyright 1996 Aidan Cully
  2. //All rights reserved
  3.  
  4. #include <QuickDraw.h>
  5. #include "graphics.h"
  6. #include "StrStuff.h"
  7.  
  8. void putline(int left,int top,int right,int bottom,long color ) {
  9.     RGBColor rgbColor;
  10.  
  11.     rgbColor.red = (color&0x000000FF)<<8;
  12.     rgbColor.blue = ((color&0x0000FF00)>>8)<<8;
  13.     rgbColor.green = ((color&0x00FF0000)>>16)<<8;
  14.     RGBForeColor( &rgbColor );
  15.     PenMode( patCopy );
  16.     MoveTo( left, top );
  17.     LineTo( right, bottom );
  18.     ForeColor( blackColor );
  19. }
  20.  
  21. unsigned char *gcvt( float num, int precision ) {
  22.     int temp;
  23.     Str32 buf;
  24.  
  25.     if( num < 0 ) {
  26.         StrCpy( buf, "\p-" );
  27.         num = -num;
  28.     } else
  29.         buf[0] = 0;
  30.     StrCat( buf, IToA( (int)num ) );
  31.     StrCat( buf, "\p." );
  32.     temp = precision-buf[0];
  33.     while( temp-- ) {
  34.         num -= (int)num;
  35.         num *= 10;
  36.         if( !(int)num )
  37.             StrCat( buf, "\p0" );
  38.         else
  39.             StrCat( buf, IToA( (int)num ) );
  40.     }
  41.     while( buf[buf[0]] == '0' )
  42.         buf[0]--;
  43.     if( buf[buf[0]] == '.' )
  44.         buf[0]--;
  45.     return( buf );
  46. }