[Drawkit] Tapering Cardinal Path

Graham Cox graham.cox at bigpond.com
Sun Jun 22 07:33:04 PDT 2008


Hi Carlos,

My approach to this would be as follows. First, create a method that  
will return the path you want based on the original path. I find  
categories great for this (on NSBezierPath, typically). Once you have  
this method you will have more freedom about how it's actually  
implemented as a DrawKit object, because you can call on that method  
whether you modify the path as part of the object, or as part of its  
style.

If you decide to make a custom object, I'd probably subclass  
DKDrawablePath in this case. It gives you more or less everything you  
need to edit it, but you can substitute the modified path by  
overriding the -renderingPath method and returning the derived path  
there.

The option of doing this as a rasterizer is also a good one, and will  
work just as well. Often doing this as a rasterizer can be more  
flexible because it allows you to mix that type of appearance with  
others. It also allows you to apply that style to any other object,  
which might be useful.

As far as your text drawing is concerned, I'm not sure if you mean the  
text should go around the outside of the path or within it and  
tapering with it. If the former, a standard DKTextAdornment will work  
if you substitute the path at the object level. If the latter, you'll  
have to code that yourself. That might work better as a rasterizer  
(either the same rasterizer as the one that draws the tapered outline/ 
fill or a separate one depending on how flexible you want to be).

I guess the main thing to realise is that there isn't one "best" way  
to do things. I usually find that implementing stylistic variations as  
rasterizers gives the most flexibility (for example arrows are  
implemented this way - there isn't a separate "arrow" object) but  
sometimes it's also handy to have objects that have specific functions  
- that's why there is a DKTextShape as well as a DKTextAdornment, even  
though there is quite a bit of overlap in what they achieve. But  
basically yes, you are on the right track.


cheers, Graham



On 22 Jun 2008, at 11:14 pm, Carlos Phillips wrote:

> Hi,
>
> I wish to create cardinal paths with tapering width. To demonstrate
> what I mean by tapered width, imagine that an arrow head is stretched
> all the way along the path. I also wish to display text along the
> tapered width of the path. I am not sure how to proceed.
>
>> From my reading of the code, I get the feeling that the steps would  
>> go
> as follows:
>
> 1) Create a DKDrawableCardinalPath class that inherits from  
> DKDrawableObject.
> The user interface for editing DKDrawableCardinalPath objects would be
> similar to DKDrawablePath's handling of straight-line paths. Would it
> be wise to subclass DKDrawablePath?
>
> 2) Create a DKTaperedStroke class that inherits from DKRasterizer.
> Gets an NSBezierPath which contains only curve segments from the
> DKDrawableObject. Create a tapered outline around this path.
>
> Am I on the right track?
>
> Will I have to render the text in DKTaperedStroke so that the text can
> flow along the tapered stroke?
>
> Thank you for any help that you can provide.
>
> Carlos
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net



More information about the Drawkit mailing list