]> git.donarmstrong.com Git - lilypond.git/commit
Change flag creation to use the 'flag prop (function returning the stencil)
authorReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 17 Jun 2008 21:25:37 +0000 (23:25 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 30 Aug 2008 11:05:21 +0000 (13:05 +0200)
commitfe0606d0a18a65234db75c7424860d656db5e6a8
tree7b0e7a2d4447d8336f35dfa8c71d61e6dcbff931
parentd62237186386a98a2c7927021669d8101f8a8cae
Change flag creation to use the 'flag prop (function returning the stencil)

-) Added the 'flag grob property to the stem: It's a function taking the
   stem grob and returning a stencil for the whole flag (including a possible
   grace slash). It uses the 'flag-style property with the exact same values
   as previously, so any existing score should still be working.
   The default is ly:stem::calc-flag (implemented in C++), but
   I also implemented the default styles (no-flag, normal-flag and
   mensural-flag) in Scheme, where the function default-flag also uses
   the 'flag-style grob property. Both (the flag creation in C++ and in
   Scheme) show practically the same performance[*], so we might get rid of
   one of them in the future. Flag creation using scheme can thus be enabled
   by
      \override Stem #'flag = #default-flag
   flag creation in C++ can be explicitly enabled by
      \override Stem #'flag = #ly:stem::calc-flag

-) Implemented the default flag styles as scheme-functions, so that one can
   re-use them in one's own flag style functions. The default flags functions
   are implemented in a modular way, so one can easily create styles that
   adjust only some aspects of the default flags. An example style implemented
   in the regression test is to use mirrored flags (i.e. flags always pointing
   to the left). This can be implemented by creating the flag for the opposite
   stem direction and rotating it by 180 degrees ;-)

-) Added regression tests to check that the default flag styles all keep
   working.

-) In the regression tests, I also added some custom styles: weighted-flag,
   where the flags are shown as one big black box and the "number" of flags
   is indicated by the height of the box. The other example is the
   mirrored-normal-flag style mentioned above (useful for tutorials about music
   notation to show that flags should *NOT* be printed to the left!)

The real motivation for this feature, namely straight flags (either
old-style with a large slant or modern-style with a much smaller slant),
is not yet implemented, but should not be too hard, using the
ly:round-filled-polygon function.

[*] We now have two ways to generate flags: One C++ implementation
(ly:stem::calc-flag) and one pure-Scheme implementation (default-flag).
Both require the same amount of memory and there is hardly any difference
in their runtime. For example, a file consisting of 10,000 eighth notes
(nothing else) needs ~1.5GB RAM and runs for a bit over 3 minutes here,
with the C++ implementation beating the Scheme implementation by mere
5 seconds:
In C++:
    real    3m9.133s
    user    3m4.896s

In Scheme:
    real    3m14.016s
    user    3m10.024s
input/regression/flags-default.ly [new file with mode: 0644]
input/regression/flags-in-scheme.ly [new file with mode: 0644]
lily/include/stem.hh
lily/staff-symbol-referencer-scheme.cc
lily/stem.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/flag-styles.scm [new file with mode: 0644]
scm/lily.scm
scm/safe-lily.scm