]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/customizing-the-position-and-number-of-dots-in-repeat-sign-bar-lines.ly
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[lilypond.git] / Documentation / snippets / customizing-the-position-and-number-of-dots-in-repeat-sign-bar-lines.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.18.0"
8
9 \header {
10   lsrtags = "scheme-language, symbols-and-glyphs"
11
12   texidoc = "
13 If you want to customize the position and/or number of dots in repeat
14 sign bar lines, you can define new custom bar lines or redefine the way
15  default repeat signs are drawn.  This snippet shows how.  This may be
16 particularly helpful when using a staff with custom line-positions, as
17 shown in this snippet.
18
19 "
20   doctitle = "Customizing the position and number of dots in repeat sign bar lines"
21 } % begin verbatim
22
23 % \version "2.18.0"
24
25 #(define ((make-custom-dot-bar-line dot-positions) grob extent)
26
27    "Draw dots (repeat sign dots) at @var{dot-positions}. The
28 coordinates of @var{dot-positions} are equivalent to the
29 coordinates of @code{StaffSymbol.line-positions}, a dot-position
30 of X and a line-position of X indicate the same vertical position."
31
32    (let* ((staff-space (ly:staff-symbol-staff-space grob))
33           (dot (ly:font-get-glyph (ly:grob-default-font grob) "dots.dot"))
34           (stencil empty-stencil))
35      (for-each
36       (lambda (dp)
37         (set! stencil (ly:stencil-add stencil
38                         (ly:stencil-translate-axis dot (* dp (/ staff-space 2)) Y))))
39       dot-positions)
40      stencil))
41
42 % With the procedure above we can define custom bar-lines, for example,
43 % one that resembles standard repeat sign bar lines except it has
44 % three dots at staff positions -3, 0, and 3.
45
46 #(add-bar-glyph-print-procedure "*" (make-custom-dot-bar-line '(-3 0 3)))
47 \defineBarLine ".|*" #'("" "*" "")
48 \defineBarLine "*|." #'("" "*" "")
49
50 % We can also customize the dot positions used in all default repeat signs
51 % by redefining the print procedure of the colon bar glyph (":"). On a staff
52 % with line-positions of '(-4 -2 2 4) the default repeat sign dots appear
53 % at '(-3 3), but we can put them at '(-1 1) instead.
54
55 #(add-bar-glyph-print-procedure ":" (make-custom-dot-bar-line '(-1 1)))
56
57
58 \new Staff \with {
59   \override StaffSymbol.line-positions = #'(-4 -2 2 4)
60   \override StaffSymbol.staff-space = #1.3
61 } {
62   \relative f' {
63     g1
64     \bar ".|*"
65     g
66     \bar "*|."
67     g
68     \bar ".|:"
69     g
70     \bar ":|."
71     g
72     \repeat volta 2 {
73       g
74     }
75   }
76 }