Re: dynamically change circle size held in NSBezierPath
Re: dynamically change circle size held in NSBezierPath
- Subject: Re: dynamically change circle size held in NSBezierPath
- From: Charlie Dickman <email@hidden>
- Date: Sun, 25 Jul 2010 16:59:10 -0400
Use the transformUsingAffineTransform: to scale your path.
On Jul 25, 2010, at 4:53 PM, Shane wrote:
> When a user decides to display a scatter plot, I iterate through all
> my points and add the x,y points to an NSBezierPath as such with a
> fixed width and height.
>
> - (void) addCoord:(double) xval yCoord:(double) yval
> {
> NSRect rect = NSMakeRect(xval, yval, 1, 1);
>
> [circlePath appendBezierPathWithOvalInRect:rect];
> }
>
> Then drawRect: gets called which draws my scatter plot coordinates.
> The problem is that, my circles are already drawn to a certain size
> and I need to scale my circles proportionately with my screen size and
> I don't know what size this will be till drawRect: gets called (e.g.
> the user may be resizing the window).
>
> …
>
> NSBezierPath *copyPath = [circlePath copy];
>
> // Move to center of screen.
> NSAffineTransform *xform = [NSAffineTransform transform];
> [xform translateXBy:(bounds.size.width * 0.50)
> yBy:(bounds.size.height * 0.50)];
>
> // Scale proportionately to screen size.
> [xform scaleBy:(xFactor / 2)];
>
> [copyPath transformUsingAffineTransform:xform];
>
> [[NSColor yellowColor] setStroke];
>
> [copyPath stroke];
>
>
> Anyone have suggestions on how to dynamically change my circle size
> for the points which are all held within an NSBezierPath?
> _______________________________________________
>
> 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
Charlie Dickman
email@hidden
_______________________________________________
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