home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / MiscKit1.2.6 / Examples / TreeView / Line.m < prev    next >
Encoding:
Text File  |  1994-05-16  |  525 b   |  34 lines

  1.  
  2. #import "Line.h"
  3.  
  4. @implementation Line
  5.  
  6. - setStart:(NXPoint *)s end:(NXPoint *)e
  7. {
  8.     start.x = s->x;
  9.     start.y = s->y;
  10.     end.x = e->x;
  11.     end.y = e->y;
  12.     return self;
  13. }
  14.  
  15. - render
  16. {
  17.     PSmoveto(start.x, start.y);
  18.     PSlineto(end.x, end.y);
  19.     PSstroke();
  20.     return self;
  21. }
  22.  
  23. - renderIfInRect:(const NXRect *)aRect
  24. {
  25.     NXRect tempRect = { { MIN(start.x, end.x), MIN(start.y, end.y) },
  26.         { MAX(ABS(start.x-end.x), 0.001), MAX(ABS(start.y-end.y), 0.001) } };
  27.     if (NXIntersectsRect(aRect, &tempRect)) {
  28.         [self render];
  29.     }
  30.     return self;
  31. }
  32.  
  33. @end
  34.