DigiScore / neoscore

A python library for notating music in a graphics-first paradigm
https://neoscore.org
BSD 3-Clause "New" or "Revised" License
108 stars 9 forks source link

Support object group deformation along curves #101

Open ajyoon opened 1 year ago

ajyoon commented 1 year ago

It would be great it neoscore could support things like curved staves. It's not obvious how this could be easily implemented though. I think a reasonable initial approach doesn't need to do add any special logic for staves, just deformation of arbitrary paths. (Note that the underlying text implementation uses paths, so in theory we should be able to implement this just for paths and get text behavior for free.) Ideally this deformation would operate as a sort of effect layer so a user could modify staff contents normally while the staff is under deformation. If users want to manipulate the path as deformed, they should be able to irreversibly commit the effect to the path contents (also irreversibly converting text objects into paths).

I see Inkscape supports this, maybe we can port their implementation.

A basis path in black, with a desired deformation path in green: original

The basis path deformed: bent

ajyoon commented 1 year ago

here's how it looks when you deform an imported musescore system naively:

staff

there are some artifacts, but i think it's a good first step

Xavman42 commented 1 year ago

The Inkscape implementation is surprisingly simple: https://gitlab.com/inkscape/inkscape/-/blob/master/src/live_effects/lpe-bendpath.cpp (putting this here mainly for personal reference)

Xavman42 commented 1 year ago

Another approach that may be mathematically simpler would be to deform a path or collection of paths to fit an envelope rather than a skeleton path or spline.

See the discussion here: https://github.com/benjamminf/warpjs/issues/11 and the implementation here: https://codepen.io/benjamminf/pen/LLmrKN