[firstPath appendBezierPath: [secondPath bezierPathByReversingPath]];
[firstPath appendBezierPath: [secondPath bezierPathByReversingPath]];
- Subject: [firstPath appendBezierPath: [secondPath bezierPathByReversingPath]];
- From: Hamish Allan <email@hidden>
- Date: Wed, 19 May 2004 05:07:10 +0100
Can anybody explain this NSBezierPath behaviour to me? When I run the
code below I get:
path 1 point at (0.250000,0.750000)
path 1 point at (0.750000,0.750000)
path 1 point at (0.750000,0.250000)
path 1 point at (0.250000,0.250000)
path 2 point at (0.250000,0.750000)
path 2 point at (0.750000,0.750000)
path 2 point at (0.750000,0.250000)
path 2 point at (0.250000,0.250000)
which seem to describe the same path, but I only see the red (path 1)
quad. (I used transparency for demonstration's sake, but the problem is
reproducible with solid color by just trying to draw each box in turn).
The code is the drawRect for a custom NSView. (It's copied from XCode,
rather than written in Mail.app.)
- (void)drawRect:(NSRect)rect
{
[self setBounds:NSMakeRect(0.0, 0.0, 1.0, 1.0)];
NSPoint topLeft = NSMakePoint(0.25, 0.75);
NSPoint topRight = NSMakePoint(0.75, 0.75);
NSPoint bottomLeft = NSMakePoint(0.25, 0.25);
NSPoint bottomRight = NSMakePoint(0.75, 0.25);
NSBezierPath *path1 = [NSBezierPath bezierPath];
[path1 moveToPoint: topLeft];
[path1 lineToPoint: topRight];
[path1 lineToPoint: bottomRight];
[path1 lineToPoint: bottomLeft];
NSBezierPath *path2 = [NSBezierPath bezierPath];
[path2 moveToPoint: topLeft];
[path2 lineToPoint: topRight];
NSBezierPath *path2b = [NSBezierPath bezierPath];
[path2b moveToPoint: bottomLeft];
[path2b lineToPoint: bottomRight];
[path2 appendBezierPath:[path2b bezierPathByReversingPath]];
unsigned int n;
int i;
n = [path1 elementCount];
for (i = 0; i < n; ++i)
{
NSPoint p;
[path1 elementAtIndex:i associatedPoints:&p];
fprintf(stderr, "path 1 point at (%f,%f)\n", p.x, p.y);
}
n = [path2 elementCount];
for (i = 0; i < n; ++i)
{
NSPoint p;
[path2 elementAtIndex:i associatedPoints:&p];
fprintf(stderr, "path 2 point at (%f,%f)\n", p.x, p.y);
}
[[[NSColor redColor] colorWithAlphaComponent:0.5] set];
[path1 fill];
[[[NSColor blueColor] colorWithAlphaComponent:0.5] set];
[path2 fill];
}
Any ideas?
Thanks in advance,
Hamish
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.