[RFC] NSScaleRect for AppKit Drawing Primitives
[RFC] NSScaleRect for AppKit Drawing Primitives
- Subject: [RFC] NSScaleRect for AppKit Drawing Primitives
- From: Grant Erickson <email@hidden>
- Date: Thu, 18 Jun 2009 17:10:11 -0700
- Thread-topic: [RFC] NSScaleRect for AppKit Drawing Primitives
While a similar effect could be achieved using NSAffineTransforms, it seems
like the following API is noticeably absent from the NSGeometry.h AppKit
drawing primitives and one I would venture many have included in their own
Cocoa toolkits:
typedef enum {
NSBottomLeftPoint,
NSMiddleLeftPoint,
NSTopLeftPoint,
NSTopCenterPoint,
NSTopRightPoint,
NSMiddleRightPoint,
NSBottomRightPoint,
NSBottomCenterPoint,
NSMiddleCenterPoint
} NSReferencePoint;
extern NSRect
NSScaleRect(NSRect aRect,
CGFloat dW,
CGFloat dH,
NSReferencePoint reference);
Description:
NSScaleRect scales the specified rectangle by the specified width and
height scalars about the specified reference point.
See http://www.tc.umn.edu/~erick205/NSScaleRect.pdf for a graphical
illustration.
Implementation:
Trivial and effectively amounts to:
NSRect scaledRect;
CGFloat dx, dy;
switch (reference) {
...
}
scaledRect.origin = aRect.origin;
scaledRect.size = NSMakeSize(NSWidth(aRect) * dW,
NSHeight(aRect) * dH);
return (NSOffsetRect(scaledRect, dx, dy));
Comments on this API, particularly as it concerns inclusion in some future
version of AppKit? Is this worth filing a Radar enhancement request for?
Regards,
Grant
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden