home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Educational / PrimeSpiral / Source / SpiralView.m < prev   
Encoding:
Text File  |  1995-06-12  |  1.2 KB  |  61 lines

  1. /* File:    SpiralView.m - View object for 'PrimeSpiral'
  2.  *
  3.  * By:        Christopher Lane
  4.  *        Symbolic Systems Resources Group
  5.  *        Knowledge Systems Laboratory
  6.  *        Stanford University
  7.  *
  8.  * Date:    26 February 1990
  9.  *
  10.  * Copyright:    1990 by The Leland Stanford Junior University.  This program
  11.  *        may be distributed without restriction for non-commercial use.
  12.  */
  13.  
  14. #import "SpiralView.h"
  15.  
  16. #import <math.h>
  17. #import <appkit/Cell.h>
  18. #import <appkit/Cursor.h>
  19. #import <dpsclient/psops.h>
  20.  
  21. #import "PrimeGenerator.h"
  22. #import "SpiralGenerator.h"
  23. #import "SpiralOps.h"
  24.  
  25. @implementation SpiralView
  26.  
  27. - spiral:sender
  28. {
  29.     NXPoint point;
  30.     PrimeGenerator *prime = [PrimeGenerator new];
  31.     SpiralGenerator *spiral = [SpiralGenerator new];
  32.     
  33.     point.x = (float) rint((double) (bounds.size.width / 2.0));
  34.     point.y = (float) rint((double) (bounds.size.height / 2.0));
  35.     
  36.     [self lockFocus];
  37.     
  38.     PSclearToGray(NX_LTGRAY);
  39.     
  40.     while(point.x > bounds.origin.x || point.y > bounds.origin.y) {
  41.         [spiral generate:[prime generate] :&point];
  42.         PSdrawAt(point.x, point.y);
  43.         }
  44.         
  45.     [self unlockFocus];
  46.     
  47.     [prime free];
  48.     [spiral free];
  49.     
  50.     return self;
  51. }
  52.  
  53. - setVersion:anObject
  54. {
  55.     [(version = anObject) setStringValue:VERSION];
  56.     
  57.     return self;
  58. }
  59.  
  60. @end
  61.