lilypond-user
[Top][All Lists]
Advanced

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

Switching the direction of slurs in tupletBracketToSlur


From: Richard Shann
Subject: Switching the direction of slurs in tupletBracketToSlur
Date: Sat, 21 May 2016 12:40:01 +0100

A while ago I asked about using slur-shaped tuplet brackets and someone
kindly posted the tupletBracketToSlur definition (pasted below).
This works nicely except that the slur is always on the same side as the
beams and stems, whereas it is usually placed on the opposite side.
I've been setting by hand but I wondered if I could set 

\override TupletBracket #'direction = #???

to some value that would result in the opposite choice to its "auto" one
in each case.

Richard

tupletBracketToSlur = {
  % Use slur-stencil
  \override TupletBracket.stencil = #ly:slur::print
  %% Use 'thickness from Slur
  \override TupletBracket.thickness = #1.2
  %% 'control-points need to be set
  \override TupletBracket.control-points =
    #(lambda (grob)
      (let* ((x-pos (ly:grob-property grob 'X-positions))
             (pos (ly:grob-property grob 'positions))
             (x-ln (interval-length x-pos))
             (dir (ly:grob-property grob 'direction))
             ;; read out the height of the TupletBracket, maybe negative!
             (height (- (cdr pos) (car pos)))
             ;; height-corr is introduced because sometimes the shape of the
             ;; slur needs to be adjusted.
             ;; It is used in the 2nd/3rd control-point.
             ;; The value of 0.3 is found by trial and error
             (height-corr (* 0.3 dir height))
             (edge-height (ly:grob-property grob 'edge-height '(0.7 . 0.7)))
             (pad 1.0))
        (list
          ;; first cp
          (cons
            (+ (car x-pos) 0.5)
            (- (+ (* dir pad) (+ (car pos) (* -1 dir (car edge-height))))
              (if (= dir -1)
                  (if (> height 3)
                    (/ dir 2.0)
                    0.0)
                  (if (< height -3)
                    (/ dir 2.0)
                    0.0))))
          ;; second cp
          (cons
            (+ (car x-pos) (* x-ln 1/4))
            (+ (* dir pad) (+ (car pos) (* dir (+ 0.5 height-corr)))))
          ;; third cp
          (cons
            (+ (car x-pos) (* x-ln 3/4))
            (+ (* dir pad) (+ (cdr pos) (* dir (- 0.5 height-corr)))))
          ;; fourth cp
          (cons
            (- (cdr x-pos) 0.5)
            (+ (* dir pad) (+ (cdr pos) (* -1 dir (cdr edge-height)))))
        )))
  \override TupletBracket.staff-padding = #'()
 
}




reply via email to

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