Re: Desktop geometry problem
Re: Desktop geometry problem
- Subject: Re: Desktop geometry problem
- From: Graham Cox <email@hidden>
- Date: Fri, 08 Jun 2012 12:45:53 +1000
On 08/06/2012, at 12:30 PM, gweston wrote:
> On Jun 07, 2012, at 10:22 PM, Graham Cox <email@hidden> wrote:
>
>>
>> On 07/06/2012, at 9:23 PM, Gregory Weston wrote:
>>
>> > Does anyone know of existing code or a trivial technique to get a CGPath or NSBezierPath that describes the shape of the desktop? I'll write and share it if it's not out there, but I'd rather not reinvent any wheels. My interests are:
>> >
>> > 1. It should be the actual perimeter of the desktop, not just the bounding box.
>> > 2. It should be a single polygon, rather than a collection of rectangles.
>> > 3. It should behave properly in the presence of mirrored displays.
>>
>>
>> Just iterate over the list of NSScreens and append each screen rect to a bezier path.
>
> First thing I tried. It fails requirement #2.
OK, so you'll need to get smart, and determine where the edges connect. With a few simple rectangles, calculating this union is a very easy problem, unlike, say, the general case of a union of arbitrary vector paths. But that can be solved, so this case is a very degenerate subset of that problem, since you know there is no overlap, nor any gaps.
I don't believe there is a built-in solution for union (or other set ops) on bezier paths, much as I'd love there to be, and have had in as a bug report for a requested feature since about 2004. The old MacOS could do this with regions (though that was a bitmap operation, so definitely simpler), but OS X has never had a public API, even though one must exist internally to calculate clipping paths and so on.
--Graham
_______________________________________________
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