(no subject)
(no subject)
- Subject: (no subject)
- From: Paul Fox <email@hidden>
- Date: Tue, 2 Jul 2002 17:46:30 +0100
To: email@hidden
Subject: Re: NSBezierPath (again) and region subtraction.
X-Mailer: Created by CRiSP-Mail v6.3 (CRiSP v8.0.6a)
Date: Tue, 2 Jul 2002 17:11:46 +0000
Dont like to follow up my own post but I may have found a solution
which others may find useful...
>
Say I have a window like so:
>
>
------------------
>
| | |
>
| | |
>
| | |
>
| 'X' NSView | <- child subview of X
>
| | |
>
------------------
>
>
If I want to draw into my view but not my subview I can create a clipping
>
region using NSBezierPath, e.g.
>
>
NSBezierPath *p1 = [NSBezierPath bezierPathWithRect: [v frame]];
>
NSBezierPath *p2 = [NSBezierPath bezierPathWithRect: ...];
>
[p1 appendBezierPath: p2];
>
[p1 setWindingRule: NSEvenOffWindingRule];
>
[p1 addClip];
>
The above code doesnt work if the child abuts the parent view.
But this _does_ seem to work:
path1 = [NSBezierPath bezierPathWithRect: NSMakeRect(
0, 0,
winp->win_parent->win_width,
winp->win_parent->win_height)];
path2 = [NSBezierPath bezierPathWithRect: NSMakeRect(
winp->win_x,
winp->win_y,
winp->win_width,
winp->win_height)];
[path1 appendBezierPath: [path2 bezierPathByReversingPath]];
[path1 setWindingRule: NSEvenOddWindingRule];
[path1 addClip];
Note the use of bezierPathByReversingPath - the documentation is real
real real bad in this area. What does 'reversing a path' mean? To me it
conjures up change the direction of a path. But I _think_ what it means
is to negate the path, or region, so you can subtract one rect from
another one.
Since there are no illustrations anywhere on the apple docs, web or
newsgroups, I thought I would add this useful example.
Not clear to me the setWindingRule is needed but it seems to
work now.
_______________________________________________
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.