Re: Neatly fitting a dash to a rect
Re: Neatly fitting a dash to a rect
- Subject: Re: Neatly fitting a dash to a rect
- From: Graham Cox <email@hidden>
- Date: Thu, 12 Dec 2013 16:52:11 +0100
On 12 Dec 2013, at 4:06 pm, Andy Lee <email@hidden> wrote:
> I assume you mean dash as in NSBezierPath's setLineDash:count:phase:.
Yep, sorry if that wasn’t clear.
> Also, does the dash have just two elements (one segment and one gap), or is it more complex.
Well, it can be more complex, but it might not matter. The remainder of the dash after the first ‘solid’ part can probably be considered as ‘gap’ for the purposes of this. Most of the time it will be a simple dash.
> Does it have to be the same exact pattern all the way around? If it's okay to differ a teeny bit (I bet imperceptibly), you could solve the problem separately for the horizontal edges and the vertical edges, and draw four lines instead of one rect.
It doesn’t *have* to be the same as long as it doesn’t differ too much visually, but detecting that a path is a simple rect (including rotated cases) and breaking it into h and v lengths might turn out to be the hard part. I also wonder if there’s a way to perform the calculation based on the highest common factor (HCF) of the horizontal and vertical edges? That might allow the dash to be tweaked as a single entity and applied in the usual way.
> Offhand, here's what comes to mind, just solving for one edge and assuming the pattern is simply { segmentLength, gapLength }.
I’ll experiment with this and see where it takes me, thanks :)
—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