This is SlidingImageView.m in view mode; [Download] [Up]
// // SlidingImageView.m // // Lennart Lovstrand, Rank Xerox EuroPARC, August 1991. // small modifications by sam 910904 #import "SlidingImageView.h" #import "Thinker.h" #import <appkit/NXImage.h> #import <appkit/Panel.h> // for NXRunAlertPanel() #import <dpsclient/wraps.h> #import <libc.h> #import <math.h> @implementation SlidingImageView - drawSelf:(const NXRect *)rects :(int)rectCount { NXPoint p; if (!rects || !rectCount) return self; [super drawSelf:rects :rectCount]; p.x = floor(imageRect.origin.x); p.y = floor(imageRect.origin.y); [image composite: NX_SOVER toPoint: &p]; return self; } - oneStep { NXPoint p; PSsetgray(0); NXRectFill(&imageRect); imageRect.origin.x += delta.x; imageRect.origin.y += delta.y; if (imageRect.origin.x < 0) { imageRect.origin.x = 0; delta.x = randBetween(.5,4); } else if (imageRect.origin.x > maxCoord.x) { imageRect.origin.x = maxCoord.x; delta.x = -randBetween(.5,4); } if (imageRect.origin.y < 0) { imageRect.origin.y = 0; delta.y = randBetween(.5,4); } else if (imageRect.origin.y > maxCoord.y) { imageRect.origin.y = maxCoord.y; delta.y = -randBetween(.5,4); } p.x = floor(imageRect.origin.x); p.y = floor(imageRect.origin.y); [image composite: NX_SOVER toPoint: &p]; return self; } - setImageConstraints { [super setImageConstraints]; if (imageRect.origin.x > maxCoord.x || imageRect.origin.y > maxCoord.y) { imageRect.origin.x = randBetween(0, maxCoord.x); imageRect.origin.y = randBetween(0, maxCoord.y); } delta.x = randBetween(.5,4); delta.y = randBetween(.5,4); return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.