Am 04.05.2012 03:09, schrieb Thomas Morley:
Hi Urs,
I would be very happy about one or two more features (that I unfortunately
can't implement myself:
- highlight (and separate from the music) the crosses through a color
- possibly adding a connecting (very thin) line, making it even more
intuitive
Best
Urs
how about:
\version "2.14.2"
#(define (make-cross-stencil coords)
(ly:stencil-add
(make-line-stencil 0.1 (- (car coords) 0.2) (- (cdr coords) 0.2)
(+ (car coords) 0.2) (+ (cdr coords) 0.2))
(make-line-stencil 0.1 (- (car coords) 0.2) (+ (cdr coords) 0.2)
(+ (car coords) 0.2) (- (cdr coords) 0.2))))
#(define (display-control-points line)
(lambda (grob)
(let ((stencil (ly:slur::print grob))
(cps (ly:grob-property grob 'control-points)))
(ly:stencil-add stencil
(ly:stencil-in-color
(make-cross-stencil (second cps))
1 0 0)
(ly:stencil-in-color
(make-cross-stencil (third cps))
1 0 0)
(if (eq? line #t)
(make-line-stencil 0.05 (car (second cps)) (cdr (second cps))
(car (third cps)) (cdr (third cps)))
empty-stencil)
)
)))
\relative c'' {
\override Slur #'stencil = #(display-control-points #t)
c2( d e f)
}
HTH,
Harm
Hi Harm,
thanks for this.
What I had in mind was to draw lines from control-points 1-2 and 3-4 (as
in drawing programs).
Your solution is equally intuitive, but I have the impression that 'my'
lines are generally smaller and therefore less intrusive, especially
with longer curves.
See the attached updated file.
In it you can see also:
- it equally works with broken slurs
- the lines are important: Take the control-point 2 of the slur in m. 2.
It is already hard to tell if this belongs to the first or the second
line - an ambiguity that isn't present in the second version with the lines.
There are two more issues with this:
- I don't see how to get it working with ties. Which would be nice of course
- It would be nice to be able to pass the color as a (optional) list of
values. So one could store the main function in a library file and
define the appearance in a 'user space' wrapper function (like in the
attached file). And it would make it possible to differentiate colors
for slurs, phrasingSlurs and Ties.
If we could continue to get a set of working tools (together with
David's shapeXXX functions), I'd try hard to find the time to document
it in some kind of tutorial (although currently I have to finish the
'real-life' project I need all this for ...)
Best
Urs
\version "2.14.2"
#(define (make-cross-stencil coords)
(ly:stencil-add
(make-line-stencil 0.15 (- (car coords) 0.2) (- (cdr coords) 0.2)
(+ (car coords) 0.2) (+ (cdr coords) 0.2))
(make-line-stencil 0.15 (- (car coords) 0.2) (+ (cdr coords) 0.2)
(+ (car coords) 0.2) (- (cdr coords) 0.2))))
#(define (display-control-points line)
(lambda (grob)
(let ((stencil (ly:slur::print grob))
(cps (ly:grob-property grob 'control-points)))
(ly:stencil-add stencil
(ly:stencil-in-color
(make-cross-stencil (second cps))
0 0 1)
(ly:stencil-in-color
(make-cross-stencil (third cps))
0 0 1)
(if (eq? line #t)
(make-line-stencil 0.05
(car (first cps)) (cdr (first cps))
(car (second cps)) (cdr (second cps)))
empty-stencil)
(if (eq? line #t)
(make-line-stencil 0.05
(car (third cps)) (cdr (third cps))
(car (fourth cps)) (cdr (fourth cps)))
empty-stencil)
)
)))
displayControlPoints = {
\override Slur #'stencil = #(display-control-points #f)
\override PhrasingSlur #'stencil = #(display-control-points #f)
%\override Tie #'stencil = #(display-control-points #f) % commenting this out
gives an error
}
displayControlPointsWithLines = {
\override Slur #'stencil = #(display-control-points #t)
\override PhrasingSlur #'stencil = #(display-control-points #t)
%\override Tie #'stencil = #(display-control-points #t) % commenting this out
gives an error
}
hideControlPoints = {
\revert Slur #'stencil
\revert PhrasingSlur #'stencil
}
\paper { indent = 0 }
music = \relative c'' {
\slurDown
c2\( d e d( c d~ d f)
\break
g e c d c1\)
}
\markup "Show control-points"
\score {
{
\displayControlPoints
\music
}
}
\markup "Show control-points and 'handle' lines"
\score {
{
\displayControlPointsWithLines
\music
}
}
\markup "Plain curves"
\score {
{
\music
}
}
_______________________________________________
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond