%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "snippets/flat-ties.ly"
\sourcefileline 0
%% DO NOT EDIT this file manually; it was automatically
%% generated from the LilyPond Wiki
%% (https://wiki.lilypond.community).
%%
%% Make any changes in the Wiki itself, or in
%% `Documentation/snippets/new/`, then run
%% `scripts/auxiliar/makelsr.pl`.
%%
%% This file is in the public domain.

\version "2.24.0"

\header {
%% Translation of GIT committish: a8a85e19654e46d725563e6deba44083ef137a2c
  texidocja = "
この関数は @code{Tie.stencil} をデフォルトの引数に取り、このデフォルトの@c
ステンシルの寸法を基にサイズが計算されます。更なる調整は
@code{Tie.details.height-limit} や @code{\\shape} で行うことができます。@c
また、カスタム定義をその場で変更することもできます。
"
  doctitleja = "平坦なタイ"

%% Translation of GIT committish: 606ac3c3b22c41d84aa5fa938d42da5125ac572a
  texidocfr = "
La fonction @code{flared-tie} ici présentée permet de dessiner une
liaison de prolongation constituée de lignes droites. Elle est sensée
remplacer la fonction par défaut de dessin des liaisons de tenue -- elle
remplace l'argument @code{stencil} de l'objet @code{Tie}.

L'argument de cette fonction @code{flared-tie} est une liste de paires
de coordonnées qui spécifient des points additionnels entre l'entame et
la terminaison afin de déterminer l'étendue des lignes de la liaison.
L'entame et la terminaison sont identiques à ceux de la liaison
originelle. La valeur des abscisses et ordonnées sont des multiples de
largeur et de la hauteur de la boîte englobante de la liaison originelle
(tout en tenant compte de son positionnement) ; par voie de conséquence,
le premier point a pour coordonnée (0,0), et le dernier point (1,0).

La fonction @code{flare-tie} définit un raccourci pour l'obtention d'une
liaison aplatie. Des ajustements plus poussés sont possibles, en
apportant des dérogations à @code{Tie.details.height-limit} ou à l'aide
de la fonction @code{\\shape}. La définition personnalisée peut aussi se
modifier à la volée.
"

  doctitlefr = "Liaison de prolongation aplatie"

%% Translation of GIT committish: 0b6116534c2f1f1cf56565ee1f2eeb9b24172c85
  texidoces = "

Este fragmento de código aporta una función @code{flared-tie} para
trazar una ligadura formada por líneas rectas.  Su objetivo es
sustituir a la función predeterminada de trazado de la ligadura
(esto es, servir como un argumento sustitutorio para la propiedad
@code{stencil} del objeto gráfico @code{Tie}).

El argumento de @code{flared-tie} es una lista de pare de
coordenadas que especifican puntos adicionales entre el primero y
el último para abarcar todas las líneas de la ligadura.  Los
puntos primero y último son idénticos a los puntos de inicio y
final de la ligadura, respectivamente.  Los valores de las
coordenadas X@tie{}e@tie{}Y son múltiplos de la longitud y la
altura del rectángulo circundante (teniendo también en cuenta la
dirección de la ligadura); por tanto, el primer punto tiene las
coordenadas (0,0), y el último (1,0).

La función @code{flare-tie} define una forma abreviada de
especificar una ligadura plana.  Es posible efectuar un trucaje
adicional de la forma mediante la sobreescritura de
@code{Tie.details.height-limit} o con la función @code{\\shape}.

También es posible cambiar la definición personalizada sobre la marcha.
"

  doctitlees = "Ligaduras planas"

  categories = "Contemporary notation, Scheme, Staff notation, Tweaks
                and overrides"

  texidoc = "
This snippet provides a function @code{flared-tie} to draw a tie that
consist of straight lines. It is intended as a replacement for the
default tie-drawing function (i.e., a replacement argument for the
@code{stencil} property of the @code{Tie} grob).

The argument of @code{flared-tie} is a list of coordinate pairs that
specify additional points between the first and last point to span up
the tie's lines. The first and last point are identical to the original
tie's start and end point, respectively. The X@tie{}and
Y@tie{}coordinate values are multiples of the bounding box length and
height of the original tie (also taking care of the tie's direction);
consequently, the first point has coordinates (0,0), and the last point
(1,0).

The function @code{flare-tie} defines a shorthand for a flat tie.
Further tweaking of the shape is possible by overriding
@code{Tie.details.height-limit} or with @code{\\shape}. It is also
possible to change the custom definition on the fly.
"

  doctitle = "Flat ties"
} % begin verbatim


#(define ((flared-tie coords) grob)
   (define (pair-to-list pair)
     (list (car pair) (cdr pair)))

   (define (normalize-coords goods x y dir)
     (map
      (lambda (coord)
        (cons (* x (car coord)) (* y dir (cdr coord))))
      goods))

   (define (my-c-p-s points thick)
     (make-connected-path-stencil points thick 1.0 1.0 #f #f))

   ;; Calling `ly:tie::print` and assigning its return value to a
   ;; variable in this outer `let` triggers LilyPond to position the
   ;; tie, allowing us to extract its extents.  We only proceed,
   ;; however, if the tie doesn't get discarded (for whatever reason).
   (let ((sten (ly:tie::print grob)))
     (if (grob::is-live? grob)
         (let* ((layout (ly:grob-layout grob))
                (line-thickness (ly:output-def-lookup layout
                                                      'line-thickness))
                (thickness (ly:grob-property grob 'thickness 0.1))
                (used-thick (* line-thickness thickness))
                (dir (ly:grob-property grob 'direction))
                (xex (ly:stencil-extent sten X))
                (yex (ly:stencil-extent sten Y))
                (lenx (interval-length xex))
                (leny (interval-length yex))
                (xtrans (car xex))
                (ytrans (if (> dir 0)(car yex) (cdr yex)))
                ;; Add last point.
                (coord-list (append coords '((1.0 . 0.0))))
                (uplist
                 (map pair-to-list
                      (normalize-coords coord-list lenx (* leny 2) dir))))
           (ly:stencil-translate
            (my-c-p-s uplist used-thick)
            (cons xtrans ytrans)))
         '())))

% Define a default tie shape consisting of three straight lines.
#(define flare-tie
   (flared-tie '((0.1 . 0.3) (0.9 . 0.3))))

\relative c' {
  a4~ a
  \once \override Tie.stencil = #flare-tie
  a4~ a \break

  <a c e a c e a c e>~ q
  \once \override Tie.stencil = #flare-tie
  q~ q\break

  <>^\markup \small \typewriter "height-limit = 14"
  \override Tie.details.height-limit = 14
  a'4~ a
  \once \override Tie.stencil = #flare-tie
  a4~ a \break

  <>^\markup \small \typewriter "height-limit = 0.5"
  \override Tie.details.height-limit = 0.5
  a4~ a
  \once \override Tie.stencil = #flare-tie
  a4~ a \break

  \revert Tie.details.height-limit

  <>^\markup \small \typewriter
             "\\shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0))"
  \shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0)) Tie
  a4~ a
  \once \override Tie.stencil = #flare-tie
  \shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0)) Tie
  a4~ a \break

  <>^\markup \small \typewriter
             "#(flared-tie '((0.2 . 2) (0.5 . -3) (0.8 . 1))"
  \once \override Tie.stencil =
        #(flared-tie '((0.2 . 2) (0.5 . -3) (0.8 . 1)))
  a4~ a
  <>_\markup \small \typewriter
             "#(flared-tie '((0.5 . 2)))"
  \once \override Tie.stencil = #(flared-tie '((0.5 . 2)))
  a'4~ a
}



% ****************************************************************
% end ly snippet
% ****************************************************************
