• 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 and setLineWidth (stupid ?) question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBezierPath and setLineWidth (stupid ?) question


  • Subject: NSBezierPath and setLineWidth (stupid ?) question
  • From: Laurent Charbonnel <email@hidden>
  • Date: Wed, 05 Sep 2001 17:58:51 -0700

I have a very simple drawRect method of a custom view that draws a grid :

- (void)drawRect:(NSRect)rect {
// Drawing code here.

float x,y;
NSBezierPath *gridPath = [NSBezierPath bezierPath];

[[NSColor redColor] set];
[gridPath setLineWidth:2.0];

for(x = _drawingRect.origin.x; x <= _drawingRect.origin.x+_drawingRect.size.width; x += _gridSpacing.width) {
[gridPath moveToPoint:NSMakePoint(x, _drawingRect.origin.y)];
[gridPath lineToPoint:NSMakePoint(x, _drawingRect.origin.y+_drawingRect.size.height)];
}

for(y = _drawingRect.origin.y; y <= _drawingRect.origin.y+_drawingRect.size.height; y += _gridSpacing.height) {
[gridPath moveToPoint:NSMakePoint(_drawingRect.origin.x, y)];
[gridPath lineToPoint:NSMakePoint(_drawingRect.origin.x+_drawingRect.size.width, y)];
}
[gridPath stroke];
}

If the value for the line width is even, nothing is drawn, but it works for odd values.
Also, if I add before the stroke command:

[gridPath lineToPoint:NSMakePoint(_drawingRect.origin.x+_drawingRect.size.width,
_drawingRect.origin.y+_drawingRect.size.height+1)];

then it works for all the values that I have tried.

What am I doing wrong ?


Thanks, Laurent.


  • Prev by Date: Re: -[NSUserDefaults initWithUser:] broken?
  • Next by Date: NSURL upload?
  • Previous by thread: NSLayoutManager behavior
  • Next by thread: NSURL upload?
  • Index(es):
    • Date
    • Thread