This is CGTMatrix.m in view mode; [Download] [Up]
/* CGTMatrix - Object encapsulation of coordinate transforms * * Authors: Adam Fedor * * This file is part of an Objective-C class library for X-window system * * CGTMatrix.m,v 1.2 1995/12/13 22:34:24 fedor Exp */ #include "CGTMatrix.h" @implementation CGTMatrix - translate: (NXPoint)point { cgt = concatCGT(cgt, composeCGT(NULL, 0, (NSPoint *)&point)); return self; } - rotate: (NXCoord)degrees { cgt = concatCGT(cgt, composeCGT(NULL, degrees, NULL)); return self; } - scale: (NXSize)scale { cgt = concatCGT(cgt, composeCGT((NSSize *)&scale, 0, NULL)); return self; } - scale:(float)x :(float)y { NXSize scale; scale.width = x; scale.height = y; return [self scale:scale]; } - concatMatrix: (cgt_t)acgt { cgt = concatCGT(cgt, acgt); return self; } - invert { invertCGT(cgt); return self; } - (NXPoint) offset { NXPoint o; NSPoint p = offsetFromCGT(cgt); o.x = p.x; o.y = p.y; return o; } - (NXSize) scale { NXSize o; NSSize p = scaleFromCGT(cgt); o.width = p.width; o.height = p.height; return o; } - (NXCoord) rotation { return rotationFromCGT(cgt); } - (cgt_t) currentMatrix { return cgt; } - (NXPoint) transformPoint: (NXPoint)aPoint { NXPoint o; NSPoint p; p.x = aPoint.x; p.y = aPoint.y; p = applyCGT(p, cgt); o.x = p.x; o.y = p.y; return o; } - (NXRect) transformRect: (NXRect)aRect { NSPoint max; NSPoint orig; max.x = NX_MAXX(&aRect); max.y = NX_MAXY(&aRect); orig.x = NX_X(&aRect); orig.y = NX_Y(&aRect); orig = applyCGT(orig, cgt); max = applyCGT(max, cgt); NX_X(&aRect) = orig.x; NX_Y(&aRect) = orig.y; NX_WIDTH(&aRect) = max.x - NX_X(&aRect); NX_HEIGHT(&aRect) = max.y - NX_Y(&aRect); return aRect; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.