Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBezierPath and setLineWidth (stupid ?) question



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.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.