[Drawkit] Tapering Cardinal Path
Carlos Phillips
amaryl at gmail.com
Sun Jun 22 13:09:26 PDT 2008
Thanks Graham, I really appreciate the help.
Given a path p returned by -renderPath as described in your answer. I
want the text to go around the outside of p. So in fact I can use
DKTextAdornment if I override -renderPath as you describe. This seems
to be the simplest solution by far.
However, as you point out, the various parts of the problem could all
be useful on their own. Cardinal paths can be useful in many
situations. Curved arrows in Omnigraffle, for example, are probably
implemented with these. A tapered width rasterizer would at the very
least be interesting if used on a general DKDrawablePath. Finally. a
rasterizer which takes the combined rendering before it, gets the
outside path and then lays out text along it would have many uses. For
example, it could be used to lay text around the zig-zags of a
DKDrawablePath rendered with DKZigZagStroke.
With your help, I have been able to produce code for the Cardinal
paths (DKDrawableCardinalPath) and the rasterizer for tapered width
(DKTaperedStroke). Neither is fully implemented but they both draw to
screen.
Unfortunately, I now see that the text rasterizer part in infeasible.
I will therefore take care of text rendering in DKTaperedStroke. The
good news is that I can probably use DKTextAdornment from within
DKTaperedStroke to render the text.
Carlos
On 22-Jun-08, at 10:33 AM, Graham Cox wrote:
> 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
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list