[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hairpin endings
From: |
Thomas Morley |
Subject: |
Re: Hairpin endings |
Date: |
Mon, 24 Apr 2017 01:15:06 +0200 |
2017-04-23 12:34 GMT+02:00 Andrew Bernard <address@hidden>:
> Next thing to do is to achieve the half dashed/half solid appearance - or
> can this be done already, in the same way that slurs can?
How about:
#(define (solid-dashed-print-proc grob startx starty endx endy)
(let* ((dash-def (ly:grob-property grob 'dash-definition))
(thick
(* (layout-line-thickness grob)
(ly:grob-property grob 'thickness 0.1))))
(if (null? dash-def)
(ly:line-interface::line grob startx starty endx endy)
(apply ly:stencil-add empty-stencil
(map
(lambda (dash-def-elt)
(let* ((start-x
(+ startx (* (- endx startx) (first dash-def-elt))))
(start-y
(+ starty (* (- endy starty) (first dash-def-elt))))
(end-x
(+ startx (* (- endx startx) (second dash-def-elt))))
(end-y
(+ starty (* (- endy starty) (second dash-def-elt)))))
(ly:stencil-translate
(ly:make-stencil
(list 'dashed-line
;; thickness
thick
;; on
(third dash-def-elt)
;; off
(- 1 (fourth dash-def-elt)) ;; calculation correct?
;; x-dest
(- end-x start-x)
;; y-dest
(- end-y start-y)
;; phase
0)
;; x-ext
(cons start-x (- end-x start-x))
;; y-ext
(ordered-cons 0 (- end-y start-y)))
(cons start-x start-y))))
dash-def)))))
#(define ((open-hairpin open-gap close-gap) grob)
(let* ((stencil (ly:hairpin::print grob))
(thick (layout-line-thickness grob))
(dir (ly:grob-property grob 'grow-direction))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (- (interval-length X-ext) thick))
(height (- (interval-length Y-ext) thick))
(scaled-height (* height (max open-gap close-gap)))
(scaled-gap (* height (min open-gap close-gap)))
(upper-stil-part
(solid-dashed-print-proc
grob
0
(/ (if (= dir -1) scaled-height scaled-gap) 2)
width
(/ (if (= dir -1) scaled-gap scaled-height) 2))))
(ly:stencil-translate
(ly:stencil-add
upper-stil-part
(ly:stencil-scale upper-stil-part 1 -1))
(cons (interval-start X-ext) (interval-start Y-ext)))))
{
c'1\> c'1 c'1\!
\once \override Hairpin.dash-definition =
#'((0 0.3 0 0.4)
(0.3 0.7 1 1)
(0.7 1.0 0.4 0.75))
%% order of arguments for 'open-hairpin' doesn't matter!
\override Hairpin.stencil = #(open-hairpin 0.2 1.0)
c'1\fff\> c'1 c'2 c'2\pppp\!
\once \override Hairpin.dash-definition =
#'((0 0.3 0 0.4)
(0.3 0.45 1 1)
(0.7 1.0 0.4 0.3))
\once \override Hairpin.thickness = 2
c'1\< c'1 c'1\!
\revert Hairpin.dash-definition
\override Hairpin.style = #'dashed-line
\once \override Hairpin.stencil = #(open-hairpin 1.0 0.5)
c'1\> c'1 c'1\!
\override Hairpin.dash-fraction = 0.3
\override Hairpin.dash-period = 1.5
\once \override Hairpin.stencil = #(open-hairpin 0.5 0.0)
c'1-\tweak thickness 3 \> c'1 c'1\!
}
HTH,
Harm
atest-55-hairpins.png
Description: PNG image
- Re: Hairpin endings, (continued)
- Re: Hairpin endings, Nathan Ho, 2017/04/21
- Re: Hairpin endings, ul, 2017/04/21
- Re: Hairpin endings, Nathan Ho, 2017/04/21
- Re: Hairpin endings, David Nalesnik, 2017/04/21
- Re: Hairpin endings, Andrew Bernard, 2017/04/23
- Re: Hairpin endings, David Nalesnik, 2017/04/23
- Re: Hairpin endings, Andrew Bernard, 2017/04/23
- Re: Hairpin endings,
Thomas Morley <=
- Re: Hairpin endings, David Nalesnik, 2017/04/23
- Re: Hairpin endings, Thomas Morley, 2017/04/24