[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hairpin solid with dashed end
From: |
Thomas Morley |
Subject: |
Re: Hairpin solid with dashed end |
Date: |
Wed, 21 Feb 2018 10:57:33 +0100 |
2018-02-21 3:25 GMT+01:00 Andrew Bernard <address@hidden>:
> Is there any example of how to make a hairpin with normal solid lines, but
> dashed at the end, say the last quarter or so? [Yep, some new complexity
> notation again.]
>
> Andrew
Hi Andrew,
some time ago I made the code below.
It will not work with a niente-circle and at line-breaks the behaviour
is not limitrd to single part of a broken Hairpin.
Nevertheless it might be a starting-point.
#(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)
(reduce 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)))))
{
\once \override Hairpin.dash-definition =
#'((0 0.7 1 1)
(0.7 1.0 0.4 0.75))
\override Hairpin.stencil = #(open-hairpin 0 1.0)
c'1\fff\> c'1 c'2 c'2\pppp\!
}
Cheers,
Harm
Re: Hairpin solid with dashed end,
Thomas Morley <=