• 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
NSBezierPath, Accessing elements of a NSBezierPath path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBezierPath, Accessing elements of a NSBezierPath path


  • Subject: NSBezierPath, Accessing elements of a NSBezierPath path
  • From: Michel Haver <email@hidden>
  • Date: Thu, 12 Jul 2001 15:12:05 +0200

I have a question about NSBezierPath functionality from the Application Kit
API Reference: Objective-C:
NSBezierPath
Accessing elements of a NSBezierPath path

- elementCount
- elementAtIndex:
- elementTypeAtIndex:associatedPoints:
- removeAllPoints
- setAssociatedPoints:atIndex:


NSBezierPath defines several methods for obtaining information about the
path elements (and their associated points) directly, including
elementAtIndex:, and elementTypeAtIndex:associatedPoints: among others. You
could use these methods to break down a path and reconstruct it point by
point.

Nice, but how does it work.

How can I access the elements of the CirclePath by using these accessors?

If I draw a Circle by using NSBezierPath how can I extract for example 12
points from the Circle, each with a 30 degrees (360/12) difference to each
other.

Thanks for all the help so far.

Code to drawCircle

- (void)drawCircle
{
NSBezierPath *circleToDraw;
NSAffineTransform *translationMatrix;
NSAffineTransform *scaleMatrix;
//Make the Circle grow with resizing MyView

NSRect myBounds = [self bounds];


//Make screenLocation grow with the NSView
//NSPoint screenLocation = NSMakePoint(50, 50);

NSPoint screenLocation = NSMakePoint(myBounds.size.width/2.0,
myBounds.size.height/2.0);


NSColor *circleStrokeColor = [NSColor blackColor];
// NSColor *circleStrokeColor = [NSColor blueColor];
// NSColor *circleFillColor = [NSColor blueColor];


float circleRadius = 150.0;

translationMatrix = [NSAffineTransform transform];
[translationMatrix translateXBy: screenLocation.x yBy:
screenLocation.y];

scaleMatrix = [NSAffineTransform transform];
[scaleMatrix scaleBy: circleRadius];

[scaleMatrix appendTransform:translationMatrix];

circleToDraw = [scaleMatrix transformBezierPath:[self circlePath]];

// [circleFillColor set];
// [circleToDraw fill];

[circleStrokeColor set];
[circleToDraw setLineWidth:2.0];
[circleToDraw stroke];


}





Cheers,

Michel


  • Follow-Ups:
    • Re: NSBezierPath, Accessing elements of a NSBezierPath path
      • From: Raphael Sebbe <email@hidden>
  • Prev by Date: Re: Status of @"" strings
  • Next by Date: Re: Annoying Java Class/Nib problem
  • Previous by thread: NSProgressIndicator disabled on sheet
  • Next by thread: Re: NSBezierPath, Accessing elements of a NSBezierPath path
  • Index(es):
    • Date
    • Thread