Nice one again, Harm! :-)
I love how every ‘normal’ person would come up with some twenty lines of
‘ordinary’ code, whereas you deliver hundreds of lines of code with a
fancy solution…
Kudos!
And, finally, (!) good night :-)
Am 06.05.2015 um 01:08 schrieb Thomas Morley:
How about:
\version "2.19.18"
%% https://code.google.com/p/lilypond/issues/detail?id=3088
%% extended
%%FIXME: add `\undertie "undertied"' to regression/markup-commands.ly
%% FIXME: c&p from stencil.scm -- define-public and remove copy
#(define (make-bezier-sandwich-stencil coords thick xext yext)
(let* ((command-list `(moveto
,(car (list-ref coords 3))
,(cdr (list-ref coords 3))
curveto
,(car (list-ref coords 0))
,(cdr (list-ref coords 0))
,(car (list-ref coords 1))
,(cdr (list-ref coords 1))
,(car (list-ref coords 2))
,(cdr (list-ref coords 2))
curveto
,(car (list-ref coords 4))
,(cdr (list-ref coords 4))
,(car (list-ref coords 5))
,(cdr (list-ref coords 5))
,(car (list-ref coords 6))
,(cdr (list-ref coords 6))
closepath)))
(ly:make-stencil
`(path ,thick `(,@' ,command-list) 'round 'round #t)
xext
yext)))
%% FIXME: rewrite generic wrt axes and replace make-parenthesis-stencil
#(define (make-bow-stencil width height thickness angularity)
"Create a bow stencil.
@var{width} is the width of the bow markup.
@var{thickness} is the thickness of the bow.
@var{height} is the heigth of the bow.
The higher the value of number @var{angularity},
the more angular the shape of the bow."
(let* ((line-width 0.1)
(base-x (if (< width 0) (- width) 0))
(base-y (if (< height 0) (- height) 0))
(x-extent (ordered-cons 0 width))
(y-extent (ordered-cons 0 height))
(left-x (interval-start x-extent))
(right-x (interval-end x-extent))
(inner-y 0)
(outer-y height)
(left-end-point (cons left-x inner-y))
(right-end-point (cons right-x inner-y))
(outer-control-y (+ inner-y (* 4/3 outer-y)))
(inner-control-y (+ outer-control-y
(if (< height 0) thickness (- thickness))))
;; keeping angularity allows for refactoring and
;; merging with make-parenthesis-stencil
(offset-index (- (* 0.6 angularity) 0.8))
(left-control-x (interval-index x-extent offset-index))
(right-control-x (interval-index x-extent (- offset-index)))
(left-outer-control-point
(cons left-control-x outer-control-y))
(right-outer-control-point
(cons right-control-x outer-control-y))
(right-inner-control-point
(cons right-control-x inner-control-y))
(left-inner-control-point
(cons left-control-x inner-control-y)))
(make-bezier-sandwich-stencil
(list right-inner-control-point
left-inner-control-point
left-end-point
right-end-point
left-outer-control-point
right-outer-control-point
right-end-point
left-end-point)
line-width
x-extent
y-extent)))
%% FIXME: replace make-parenthesis-stencil by this:
#(define (make-parenthesis-stencil height width thick angularity)
(ly:stencil-rotate-absolute
(make-bow-stencil height width thick angularity)
-90 0 0))
%% FIXME: c&p from bezier-bow.cc
#(define (F0_1 x) (* (/ 2 PI) (atan (* PI x 0.5))))
#(define (slur-height w h_inf r_0)
(F0_1 (* (/ (* w r_0) h_inf) h_inf)))
#(define (make-tie-stencil width thickness direction)
(let* ((height-limit 1)
(ratio 0.25)
(angularity 0.5)
(height (slur-height width height-limit ratio)))
(make-bow-stencil width (* direction height) thickness angularity)))
#(define-markup-command (undertie layout props arg)
(markup?)
#:category font
#:properties ((thickness 1)
(offset 2)
(direction DOWN)
(adjust-length 0)
(adjust-x-pos 0))
"
@cindex undertie-ing text
Undertie @var{arg}. Looks at @code{thickness} to determine line
thickness, and @code{offset} to determine line y-offset.
@lilypond[verbatim,quote]
\\markup \\line {
\\undertie \"undertied\"
\\override #'(offset . 5)
\\override #'(thickness . 1)
\\undertie \"undertied\"
\\override #'(offset . 1)
\\override #'(thickness . 5)
\\undertie \"undertied\"
}
@end lilypond"
(let* ((line-thickness (ly:output-def-lookup layout 'line-thickness))
(thick (* thickness line-thickness))
(markup (interpret-markup layout props arg))
(x1 (car (ly:stencil-extent markup X)))
(x2 (cdr (ly:stencil-extent markup X)))
(y2 (cdr (ly:stencil-extent markup Y)))
(w (- x2 x1 adjust-length (* 2 line-thickness)))
(y (if (positive? direction)
(+ line-thickness offset -2 y2)
(* line-thickness (- offset))))
(tie (ly:stencil-translate
(make-tie-stencil w thick direction)
(cons (+ line-thickness adjust-x-pos) y))))
(ly:stencil-add markup tie)))
%%%%%%%%%%%%%%%
%% Examples
%%%%%%%%%%%%%%%
\paper { indent = 0 }
\markup {
\fill-line {
\fontsize #3 \bold \underline "toplevel Markup: "
\column {
\vspace #0.5
\line { \bold "2."
\column {
\line {
Er ging aus der Kammer sein, /
dem
\override #'(adjust-x-pos . 0.5)
\override #'(adjust-length . 7.7)
\undertie königlichen Saal so rein, /
}
"Gott von Art und Mensch, ..."
}
}
\vspace #2
}
}
}
\markup \fontsize #3 \bold \underline "new Lyrics: "
\new Lyrics
\lyricmode {
Er ging aus der Kammer sein, dem
\markup
\override #'(adjust-x-pos . 0.5)
\override #'(adjust-length . 8.6)
\undertie königlichen Saal so rein,
Gott von Art und Mensch,
}
Cheers,
Harm
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user