[Drawkit] warped/warpable grid?
Graham Cox
graham.cox at bigpond.com
Sun Jun 8 03:54:11 PDT 2008
Hi James,
It's unlikely that a grid like this would be worth my while writing as
a general DK class, is it sounds pretty unique to your situation. I
could just about buy the need for logarithmic or polar grids but even
then I doubt they'd be all that worthwhile for general-purpose use.
In terms of drawing the grid and snapping a point to a given grid
position, DKGridLayer does already give you most of what you need. As
long as you can actually come up with a way to reliably describe your
grid, you can implement it. To draw the grid, override the -
createGridCacheInRect: method and use it to set up the NSBezierPath
objects that are drawn to display the grid. To snap a given point to
the grid, override the -nearestGridIntersectionToPoint: method and do
what you need to do to return the right point. The nudge feature is
more difficult at present because it assumes that the grid has a
constant linear increment - that's something I can change so it nudges
to the next gridline from the current point (I think - I haven't
looked at the code in detail or remember exactly how it's implemented).
You'll also find it won't be possible to synch up a non-linear grid to
NSRulerView unless you also subclass it, but your timeline might
already be providing that feature.
cheers, Graham
On 7 Jun 2008, at 2:07 am, James Maxwell wrote:
> Actually, I just realized that I'd also be talking about a grid
> which is asymmetric along the x and y axes, which is probably kind
> of unusual... It seems pretty clear that I'll need to make a fairly
> complex subclass of DKGridLayer, if I want to take this route, but
> any thoughts would still be appreciated. I'm thinking particularly
> of whether this might be something worth including in the framework,
> in general, Graham(??).
>
> cheers,
>
> J.
>
>
> On 6-Jun-08, at 8:54 AM, James Maxwell wrote:
>
>> Hello All,
>>
>> For the musical space I'm working on I need what could really be
>> thought of as a "warped" grid. That is, a grid which is capable of
>> having a changing spans, majors, and divisions - at least along the
>> x-axis. A set division value for the y-axis would be fine (I don't
>> even really need a y-axis grid, though it might provide a handy
>> shortcut for some purposes). Also, the variable x-axis grid should
>> be editable by the user (i.e., dynamically changing spans, majors,
>> divisions).
>>
>> I've been looking over DKGridLayer.m, but there doesn't seem to be
>> support for this kind of grid. Basically, I need to be able to mark
>> an x-axis place on the grid as a new "origin", and change the grid
>> spacing from that point "forward" (i.e., left-to-right in musical
>> time). I have built a simple timeline object, which maintains
>> something similar to a grid, which I could use for this purpose,
>> but it would be more elegant to use a grid layer, to benefit from
>> the integration with DK. In particular, it appears that the nudge
>> amounts are dictated by the grid, so it would be nice to pick up
>> the nudge functionality, without having to re-write it from scratch.
>>
>> I know this is not a function that many people would likely need,
>> but it could still find uses in other types of applications, I
>> think. Any thoughts on how to go about doing this would be
>> appreciated.
>>
>> cheers,
>>
>> J.
>> _______________________________________________
>> 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