lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Colored arrows (alternative method)


From: Big Noise
Subject: Colored arrows (alternative method)
Date: Sat, 06 Dec 2014 17:40:33 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

Hi everyone,

in this thread I'll continue a "side product" from another thread:
http://lilypond.1069038.n5.nabble.com/scheme-problem-colored-background-layers-tc169023.html

The idea was to create colored arrows that automatically adapt to layout changes.
Thanks to Urs and Malte for your ideas on that.

Here is my first attempt:

% --------------------------------------------------------------------------
\version "2.18.2"

forwardArrow = #(define-music-function (parser location color)
                  (color?)
                  #{ % Cross-staff arrows are made using the VoiceFollower:
                    \once \override VoiceFollower.layer = #-5
                    % To have the arrow behind the staff, choose a value below 
0 for the layer.
                    % If you want the arrows to cover the notes, choose a value 
of 2 or more.
                    \once \override VoiceFollower.thickness = #'5    % line 
thickness
                    \once \override VoiceFollower.color = #color
                    \once \override VoiceFollower.bound-details.left.padding = 
#4
                    \once \override VoiceFollower.bound-details.right.padding = 
#5
                    % Padding can be adjusted to move arrow ends closer to the 
notes
                    \once \override VoiceFollower.bound-details.right.arrow = 
##t
                    \once \override VoiceFollower.breakable = ##t  % ##f 
prevents line breaks within an arrow
                    % Arrows within the same staff use the Glissando spanner:
                    \once \override Glissando.layer = #-5
                    \once \override Glissando.thickness = #'5
                    \once \override Glissando.color = #color
                    \once \override Glissando.bound-details.left.padding = #4
                    \once \override Glissando.bound-details.right.padding = #5
                    \once \override Glissando.bound-details.right.arrow = ##t
                    \once \override Glissando.breakable = ##t
                  #})

backwardArrow = #(define-music-function (parser location color)
                  (color?)
                  #{
                    \once \override VoiceFollower.layer = #-5
                    \once \override VoiceFollower.thickness = #'5    % line 
thickness
                    \once \override VoiceFollower.color = #color
                    \once \override VoiceFollower.bound-details.left.padding = 
#4
                    \once \override VoiceFollower.bound-details.right.padding = 
#5
                    % pretty much the same stuff, but arrow head at the left 
side:
                    \once \override VoiceFollower.bound-details.left.arrow = ##t
                    \once \override VoiceFollower.breakable = ##t
                    \once \override Glissando.layer = #-5
                    \once \override Glissando.thickness = #'5
                    \once \override Glissando.color = #color
                    \once \override Glissando.bound-details.left.padding = #4
                    \once \override Glissando.bound-details.right.padding = #5
                    \once \override Glissando.bound-details.left.arrow = ##t % 
same here...
                    \once \override Glissando.breakable = ##t
                  #})


\relative c' {
  <<
    % Usage: place the arrow function call before the note, the glissando 
statement after the note
    \new Staff = upper {c4 d e \backwardArrow #blue c \glissando    R1   R1   
R1   R1   R1   c4 d e c   e1 d c}
    \new Staff = middle {R1    c4 d e c   e8 d e f g f e c    d c d e f e f d   
 c1    R1    R1*4}
    \new Staff = lower
    {<<
      {R1   R1    c4 d e \forwardArrow #blue c\glissando    R1   c4 d e c    d 
c b2    R1*4}
      { % Cross-staff arrows use an additional voice with hidden notes between 
them.
        % To make these notes visible, uncomment the following line:
        %      \override NoteHead.color = #cyan \override NoteHead.layer = #2
        % and remove the following "\hideNotes" line:
        \hideNotes
        \set Voice.followVoice = ##t
        \change Staff = "upper"  c4 s2.
        % place the arrow function call immediately before the staff change:
        \backwardArrow #green
        \change Staff = "middle"  g4 s2.
        \forwardArrow #red
        \change Staff = "lower"  c4  s2.    s1    c4 s2.
        \break
        \forwardArrow #red
        \change Staff = "middle"  c4 s2.
        \forwardArrow #red
        \change Staff = "upper"  c4 s2.
      }
    >>}
  >>
}

% --------------------------------------------------------------------------

Any suggestions for improvement? (I'll wait for you before turning this one into a snippet...)

Cheers,
Klaus



Am 04.12.2014 um 18:01 schrieb address@hidden:

From: Malte Meyn To: address@hidden Subject: Re: scheme problem: colored background, layers Am 04.12.2014 um 00:13 schrieb Urs Liska:

Am I seeing correctly that the arrows are coded with absolute
coordinates from their starting points (i.e. they wouldn't adapt to
layout changes)?
This is not at all diminishing your snippet, but it would be absolutely
awesome if someone could extend this to override the stencil of, say, a
slur, so the arrows would "snap" to two notes.

Probably a glissando or a voice follower (both engraved by the
Note_head_line_engraver) would be better/easier to reuse than a slur
since these arrws look like some sort of ?voice following? ;)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]