X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fsnippets%2Fgenerating-custom-flags.ly;h=a1121ae24cde3effbc2f8272ac566784e561f2eb;hb=2501bd6a985bab5d5c7a744b15429727293efa45;hp=180e27e14ccb201f95ef6d567a6aed7491b3a754;hpb=144cd434d02e6d90b2fb738eeee99119a7c5e1d2;p=lilypond.git diff --git a/Documentation/snippets/generating-custom-flags.ly b/Documentation/snippets/generating-custom-flags.ly index 180e27e14c..a1121ae24c 100644 --- a/Documentation/snippets/generating-custom-flags.ly +++ b/Documentation/snippets/generating-custom-flags.ly @@ -1,25 +1,29 @@ -%% Do not edit this file; it is automatically -%% generated from LSR http://lsr.dsi.unimi.it +%% DO NOT EDIT this file manually; it is automatically +%% generated from LSR http://lsr.di.unimi.it +%% Make any changes in LSR itself, or in Documentation/snippets/new/ , +%% and then run scripts/auxiliar/makelsr.py +%% %% This file is in the public domain. -\version "2.13.31" +\version "2.18.0" \header { lsrtags = "rhythms, tweaks-and-overrides" texidoc = " -The @code{flag} property of the Stem grob can be set to a custom scheme -function to generate the glyph for the flag. +The @code{stencil} property of the @code{Flag} grob can be set to a +custom scheme function to generate the glyph for the flag. " doctitle = "Generating custom flags" } % begin verbatim -#(define-public (weight-flag stem-grob) - (let* ((log (- (ly:grob-property stem-grob 'duration-log) 2)) +#(define-public (weight-flag grob) + (let* ((stem-grob (ly:grob-parent grob X)) + (log (- (ly:grob-property stem-grob 'duration-log) 2)) (is-up? (eqv? (ly:grob-property stem-grob 'direction) UP)) (yext (if is-up? (cons (* log -0.8) 0) (cons 0 (* log 0.8)))) (flag-stencil (make-filled-box-stencil '(-0.4 . 0.4) yext)) - (stroke-style (ly:grob-property stem-grob 'stroke-style)) + (stroke-style (ly:grob-property grob 'stroke-style)) (stroke-stencil (if (equal? stroke-style "grace") (make-line-stencil 0.2 -0.9 -0.4 0.9 -0.4) empty-stencil))) @@ -27,13 +31,14 @@ function to generate the glyph for the flag. % Create a flag stencil by looking up the glyph from the font -#(define (inverted-flag stem-grob) - (let* ((dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "d" "u")) - (flag (retrieve-glyph-flag "" dir "" stem-grob)) - (line-thickness (ly:staff-symbol-line-thickness stem-grob)) +#(define (inverted-flag grob) + (let* ((stem-grob (ly:grob-parent grob X)) + (dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "d" "u")) + (flag (retrieve-glyph-flag "" dir "" grob)) + (line-thickness (ly:staff-symbol-line-thickness grob)) (stem-thickness (ly:grob-property stem-grob 'thickness)) (stem-width (* line-thickness stem-thickness)) - (stroke-style (ly:grob-property stem-grob 'stroke-style)) + (stroke-style (ly:grob-property grob 'stroke-style)) (stencil (if (null? stroke-style) flag (add-stroke-glyph flag stem-grob dir stroke-style ""))) @@ -43,21 +48,20 @@ function to generate the glyph for the flag. snippetexamplenotes = { \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64 } { - \override Score.RehearsalMark #'self-alignment-X = #LEFT + \override Score.RehearsalMark.self-alignment-X = #LEFT \time 1/4 \mark "Normal flags" \snippetexamplenotes \mark "Custom flag: inverted" - \override Stem #'flag = #inverted-flag + \override Flag.stencil = #inverted-flag \snippetexamplenotes \mark "Custom flag: weight" - \override Stem #'flag = #weight-flag + \override Flag.stencil = #weight-flag \snippetexamplenotes \mark "Revert to normal" - \revert Stem #'flag + \revert Flag.stencil \snippetexamplenotes } -