• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[RFC] NSScaleRect for AppKit Drawing Primitives
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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

  • Follow-Ups:
    • moderator Re: [RFC] NSScaleRect for AppKit Drawing Primitives
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: What is the best way to store some kind of identifying string in an interface builder object?
  • Next by Date: Re: Enter Key Behavior in NSTableView
  • Previous by thread: continuous spell checking, NSTextView / field editor, document tag
  • Next by thread: moderator Re: [RFC] NSScaleRect for AppKit Drawing Primitives
  • Index(es):
    • Date
    • Thread