LSR/748

< LSR
Zur Navigation springen Zur Suche springen
PD Der Inhalt dieser Seite wurde aus dem LilyPond Snippet Repository übernommen und steht unter folgender Lizenz: CC0.
See Public Domain Help Pages for more info.
PD
Modifying a slur by offsetting the positions property

LSR Snippet Nr. 748

Beschreibung

One way to modify the shape of a slur is to override its positions property (see this snippet). To do so, however, you must specify a value for both the beginning and end of the slur. This function allows you to tweak a slur by changing the default value of just one of its endpoints, which can mean less trial and error. It is particularly useful when you want to leave one end of a slur as it is: just set its offset to zero.

Syntax: \offsetPositions #'(y1 . y2)

auto
%% http://lsr.di.unimi.it/LSR/Item?id=748
%% see also http://www.lilypond.org/doc/v2.17/Documentation/notation/modifying-shapes

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A function to modify the shape of slurs by offsetting the positions property
% from default control-point values. Setting either y1 or y2 to zero will leave
% that attachment-point unchanged. Syntax: \offsetPositions #'(y1 . y2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

offsetPositions =
  #(define-music-function (offsets) (pair?)
    #{
%% deprecated, will delete soon --Harm
%       \once \override Slur.positions = #(lambda (grob) 
%	 `(,(+ (car offsets) (cdar (ly:slur::calc-control-points grob))) . 
%	   ,(+ (cdr offsets) (cdr (cadddr (ly:slur::calc-control-points grob))))))
	   
	   \once \override Slur.after-line-breaking = 
	     #(lambda (grob) 
	       (let ((cpf (ly:grob-property-data grob 'control-points))
                 (cps (ly:grob-property grob 'control-points)))
	         (ly:grob-set-property! grob 'positions 
	           (cons
	             (+ (car offsets)
	                (cdr (first cps)))
	             (+ (cdr offsets)
	                (cdr (last cps)))))
             (ly:grob-set-property! grob 'control-points 
               (ly:unpure-call cpf grob)))) 
    #})

\relative c'' {
  c4(^"default" c, d2)
  \offsetPositions #'(0 . 1)
  c'4(^"(0 . 1)" c, d2)
  \offsetPositions #'(0 . 2)
  c'4(^"(0 . 2)" c, d2)
  \bar "||"
  g4(^"default" a d'2)
  \offsetPositions #'(1 . 0)
  g,,4(^"(1 . 0)" a d'2)
  \offsetPositions #'(2 . 0)
  g,,4(^"(2 . 0)" a d'2)
}
%% http://lsr.di.unimi.it/LSR/Item?id=748
%% see also http://www.lilypond.org/doc/v2.17/Documentation/notation/modifying-shapes

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A function to modify the shape of slurs by offsetting the positions property
% from default control-point values. Setting either y1 or y2 to zero will leave
% that attachment-point unchanged. Syntax: \offsetPositions #'(y1 . y2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

offsetPositions =
  #(define-music-function (offsets) (pair?)
    #{
%% deprecated, will delete soon --Harm
%       \once \override Slur.positions = #(lambda (grob) 
%	 `(,(+ (car offsets) (cdar (ly:slur::calc-control-points grob))) . 
%	   ,(+ (cdr offsets) (cdr (cadddr (ly:slur::calc-control-points grob))))))
	   
	   \once \override Slur.after-line-breaking = 
	     #(lambda (grob) 
	       (let ((cpf (ly:grob-property-data grob 'control-points))
                 (cps (ly:grob-property grob 'control-points)))
	         (ly:grob-set-property! grob 'positions 
	           (cons
	             (+ (car offsets)
	                (cdr (first cps)))
	             (+ (cdr offsets)
	                (cdr (last cps)))))
             (ly:grob-set-property! grob 'control-points 
               (ly:unpure-call cpf grob)))) 
    #})

\relative c'' {
  c4(^"default" c, d2)
  \offsetPositions #'(0 . 1)
  c'4(^"(0 . 1)" c, d2)
  \offsetPositions #'(0 . 2)
  c'4(^"(0 . 2)" c, d2)
  \bar "||"
  g4(^"default" a d'2)
  \offsetPositions #'(1 . 0)
  g,,4(^"(1 . 0)" a d'2)
  \offsetPositions #'(2 . 0)
  g,,4(^"(2 . 0)" a d'2)
}

Unterseiten