This is ScaledView.m in view mode; [Download] [Up]
/*
** Copyright (c) 1995 Friday Software & Consulting, Inc. All Rights Reserved.
**
** Author: <bbum@friday.com>
**
** Do Not Take This Code Seriously!
*/
/* This object is included in the MiscKit by permission from the author
** and its use is governed by the MiscKit license, found in the file
** "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
** for a list of all applicable permissions and restrictions.
*/
#import <appkit/appkit.h>
#import "FooFaraw.h"
#import "ScaledView.h"
#define NUMLINES 305
@implementation ScaledView : FooFaraw
- initFrame:(const NXRect *)frameRect
{
register int jkl;
// about the 3 -- don''t ask, it looks good.
x1=(float *)malloc(sizeof(float) * (NUMLINES +3));
yc1=(float *)malloc(sizeof(float) * (NUMLINES +3));
t1=(float *)malloc(sizeof(float) * (NUMLINES +3));
t2=(float *)malloc(sizeof(float) * (NUMLINES +3));
t3=(float *)malloc(sizeof(float) * (NUMLINES +3));
[super initFrame:frameRect];
for(jkl=0;jkl<NUMLINES;jkl++){
x1[jkl]=midx;
yc1[jkl]=midy;
}
// line per is the percentage back that erase steps
lper=NUMLINES-5;
return self;
}
- oneStep
{
float mx, my;
pp=p; p=n;
n=(n+1)%(NUMLINES-1);
PScurrentmouse(winNum, &mx, &my);
if (bigMode){
xi=((mx-midx)/urx)*50;
yi=((my-midy)/ury)*50;
} else {
xis=((mx-midx)/urx)*3;
yis=((my-midy)/ury)*3;
}
if(!count || ((count++>500) && (((mx != oldx) && (my != oldy)) ||
(count>30000)))){
count=1;
PSsetgray(0.0);
NXRectFill(&bounds);
}
oldx=mx; oldy=my;
t1[n]=t1[p]+0.2*(xi+xis); if(t1[n]>(2*M_PI)) t1[n]-=(2*M_PI);
t2[n]=t2[p]+0.2*(yi+yis); if(t2[n]>(2*M_PI)) t2[n]-=(2*M_PI);
t3[n]=t3[p]+0.01; if(t3[n]>(2*M_PI)) t3[n]-=(2*M_PI);
x1[n]=(cos(t1[n])*s1) + (cos(t2[n])*s3) + midx;
yc1[n]=(sin(t1[n])*s2) + (sin(t2[n])*s4) + midy;
PSsetrgbcolor((cos(t1[n])+1.0)/2.0,
(cos(t2[n])+1.0)/2.0,
(cos(t3[n])+1.0)/2.0);
PSnewpath();
PSmoveto(x1[pp], yc1[pp]);
PSlineto(x1[p], yc1[p]);
PSlineto(x1[n], yc1[n]);
PSclosepath();
PSfill();
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.