home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / BMV / Source / ScaledView.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  1.8 KB  |  80 lines

  1. #import "ScaledView.h"
  2. #import <appkit/NXImage.h>
  3. #import <appkit/Window.h>
  4. #import <appkit/Panel.h>                // for NXRunAlertPanel()
  5. #import <dpsclient/wraps.h>
  6. #import <libc.h>
  7. #import <math.h>
  8.  
  9. #define NUMLINES 305
  10.  
  11. @implementation ScaledView : FooFaraw
  12. - initFrame:(NXRect *)frameRect
  13. {
  14.   register int jkl;
  15.   
  16.   // about the 3 -- don''t ask, it looks good.
  17.   x1=(float *)malloc(sizeof(float) * (NUMLINES +3));
  18.   yc1=(float *)malloc(sizeof(float) * (NUMLINES +3));
  19.   t1=(float *)malloc(sizeof(float) * (NUMLINES +3));
  20.   t2=(float *)malloc(sizeof(float) * (NUMLINES +3));
  21.   t3=(float *)malloc(sizeof(float) * (NUMLINES +3));
  22.  
  23.   [super initFrame:frameRect];
  24.  
  25.   for(jkl=0;jkl<NUMLINES;jkl++){
  26.     x1[jkl]=midx;
  27.     yc1[jkl]=midy;
  28.   }
  29.   // line per is the percentage back that erase steps
  30.   lper=NUMLINES-5;
  31.   return self;
  32. }  
  33.  
  34. - oneStep
  35. {
  36.   float mx, my;
  37.  
  38.     pp=p; p=n;
  39.     n=(n+1)%(NUMLINES-1);
  40.     
  41.     PScurrentmouse(winNum, &mx, &my);
  42.     if (bigMode){
  43.       xi=((mx-midx)/urx)*50;
  44.       yi=((my-midy)/ury)*50;
  45.     } else {
  46.       xis=((mx-midx)/urx)*3;
  47.       yis=((my-midy)/ury)*3;
  48.     }
  49.     
  50.     if(!count || ((count++>500) && (((mx != oldx) && (my != oldy)) ||
  51.                     (count>30000)))){
  52.       count=1;
  53.       PSsetgray(0.0);
  54.       NXRectFill(&bounds);
  55.     }
  56.     oldx=mx; oldy=my;
  57.     
  58.     
  59.     t1[n]=t1[p]+0.2*(xi+xis); if(t1[n]>(2*M_PI)) t1[n]-=(2*M_PI);
  60.     t2[n]=t2[p]+0.2*(yi+yis); if(t2[n]>(2*M_PI)) t2[n]-=(2*M_PI);
  61.     t3[n]=t3[p]+0.01;   if(t3[n]>(2*M_PI)) t3[n]-=(2*M_PI);
  62.     
  63.     x1[n]=(cos(t1[n])*s1) + (cos(t2[n])*s3) + midx;
  64.     yc1[n]=(sin(t1[n])*s2) + (sin(t2[n])*s4) + midy;
  65.     
  66.     PSsetrgbcolor((cos(t1[n])+1.0)/2.0,
  67.           (cos(t2[n])+1.0)/2.0,
  68.           (cos(t3[n])+1.0)/2.0);
  69.     
  70.     PSnewpath();
  71.     PSmoveto(x1[pp], yc1[pp]);
  72.     PSlineto(x1[p], yc1[p]);
  73.     PSlineto(x1[n], yc1[n]);
  74.     PSclosepath();
  75.     PSfill();
  76.  
  77.   return self;
  78. }
  79. @end
  80.