• 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 setLineWidth with extreme view bounds aspect ratios.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBezierPath setLineWidth with extreme view bounds aspect ratios.


  • Subject: NSBezierPath setLineWidth with extreme view bounds aspect ratios.
  • From: Greg Best <email@hidden>
  • Date: Sun, 5 Aug 2007 16:59:13 -0700

Hi--

I'm trying to put together a plotting routine to plot curves on an axis. Seemed the easiest way to do so was to set the NSView bounds to the extent of my dataset and then to draw the curves onto that using the natural data points as coordinates.

The problem comes when setting line widths for the NSBezierPaths. It seems that the line widths all assume square "pixels". If I set the NSView bounds width to 10000, but the height to 1000 (in a square frame) and set my line width to 0 then my vertical lines are nice and thin but the horizontal lines are quite thick.

I think this comes from the fact that there is only one width parameter and it is in NSView lengths, not pixels measured across the line. Is there a way for me to keep a consistent width on all lines regardless of their orientation without being forced to keep my bounds and frame aspect ratios the same and manually transform all of my points?


I'm attaching a sample drawRect method to illustrate what I'm talking about. This isn't just an artifact of setting line width to zero-- the same effect occurs with any fixed number. As the oval path shows, this particularly problematic when drawing continuous curves because the line width can't be easily compensated before the draw.


- (void)drawRect:(NSRect)rect
{
NSRect b;
[self setBounds:NSMakeRect(-40000,-1000,80000,2000)];
b=[self bounds];
[NSBezierPath setDefaultLineWidth:0];
[NSBezierPath strokeLineFromPoint:NSMakePoint(NSMinX(b),0) toPoint:NSMakePoint(NSMaxX(b),0)];
[NSBezierPath strokeLineFromPoint:NSMakePoint(0,NSMinY(b)) toPoint:NSMakePoint(0,NSMaxY(b))];
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(NSMinX(b) +NSWidth(b)/4,NSMinY(b)+NSHeight(b)/4,
NSWidth(b)/ 2,NSHeight(b)/2)] stroke];
}



Thanks, Greg

_______________________________________________

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


  • Prev by Date: Re: Drag with NSTableview
  • Next by Date: Problem with bindings and Shared User Defaults
  • Previous by thread: Re: Control doesn't stay centered?
  • Next by thread: Problem with bindings and Shared User Defaults
  • Index(es):
    • Date
    • Thread