[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: override stencil question
From: |
priosfilho |
Subject: |
Re: override stencil question |
Date: |
Thu, 4 Jun 2015 14:41:11 -0700 (MST) |
Sorry, Nathan. I will try to make my point clearer.
*Firstly*, I got the code developed earlier in this thread and altered the
numbers of handles of path-gliss to four -- the original version came with
the values (list 'curveto 0 0 (first handle) (second handle)).
Here's my version of the code:
\version "2.18.2"
glissWidth = #0.175 %<< global variable for glissando width
#(define (path-gliss handle)
(lambda (grob)
(if (ly:stencil? (ly:line-spanner::print grob))
(let* ((stencil (ly:line-spanner::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(height (interval-length Y-ext))
(lefty (cdr (assoc 'Y (ly:grob-property grob 'left-bound-info))))
(righty (cdr (assoc 'Y (ly:grob-property grob
'right-bound-info))))
(deltay (- righty lefty))
(dir (if (> deltay 0) 1 -1))
)
(ly:stencil-translate
(grob-interpret-markup grob
(markup
;(#: tiny (format "~a" (ly:grob-properties grob)))
;(format "~a" (cdr (assoc 'Y (ly:grob-property grob
'left-bound-info))))
;(#: tiny (format "~a" handle))
(#:path glissWidth
(list (list 'moveto 0 0)
(list 'curveto (first handle) (second handle) (third
handle) (fourth
handle) width (* height dir))))))
(if (> dir 0)
(cons (interval-start X-ext) (+ (interval-start Y-ext) 0.1))
(cons (interval-start X-ext) (+ (interval-start Y-ext)
height)))))#f)))
#(define (add-gliss m)
(case (ly:music-property m 'name)
((NoteEvent) (set! (ly:music-property m 'articulations)
(append (ly:music-property m 'articulations)
(list (make-music (quote GlissandoEvent)))))
m)
(else #f)))
addGliss = #(define-music-function (parser location music)
(ly:music?)
(map-some-music add-gliss music))
\relative c' {
\numericTimeSignature
\tempo 4=52
\override NoteHead.font-size = #-1.5
$(add-grace-property 'Voice 'NoteHead 'font-size -4.5)
\time 5/8
\override Score.GraceSpacing.spacing-increment = #7
\once \override Glissando #'bound-details =
#'((right (attach-dir . -2) (end-on-accidental .
#f) (padding . 1))
(left (attach-dir . 0) (padding . 0.)))
\addGliss {
\once \override Glissando #'stencil = #(path-gliss '(7 1 0 4))
\grace b16
a''4.~->}
\tuplet 5/4 { a16 gis fis, e'-> a,~ }
\time 3/8
}
With that, i am able to get that (missing only the arrowhead to get what I
want):
<http://lilypond.1069038.n5.nabble.com/file/n177488/example1.png>
---
Then, I got your useful version and was able to get that:
\version "2.18.2"
arc = #(list 0 0) %<< global variable to bezier curve handle
glissWidth = #0.2 %<< global variable for glissando width
#(define (set-arc x y)
(set! arc (list x y)))
#(define (get-arc)
arc)
#(define (radians->degrees theta)
(* theta (/ 180 PI)))
#(define (path-gliss grob)
(if (ly:stencil? (ly:line-spanner::print grob))
(let* ((stencil (ly:line-spanner::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(height (interval-length Y-ext))
(lefty (cdr (assoc 'Y (ly:grob-property grob
'left-bound-info))))
(righty (cdr (assoc 'Y (ly:grob-property grob
'right-bound-info))))
(deltay (- righty lefty))
(dir (if (> deltay 0) 1 -1))
(handle (get-arc))) ;<<------------- getting the
handle value here
(ly:stencil-translate
(ly:stencil-add
(grob-interpret-markup grob
(markup
;(#: tiny (format "~a" (ly:grob-properties grob)))
;(format "~a" (cdr (assoc 'Y (ly:grob-property grob
'left-bound-info))))
;(#: tiny (format "~a" handle))
(#:path glissWidth
(list (list 'moveto 0 0)
(list 'curveto 0 0 (first handle)
(second handle) width (* height dir))))))
(ly:stencil-translate
; the \rotate markup command doesn't let us pick a rotation
center, so we resort to the stencil command
(ly:stencil-rotate
(grob-interpret-markup grob
(markup #:arrow-head X RIGHT #t))
(radians->degrees
($atan2
(- (* height dir) (second handle))
(- width (first handle)))) 1 0)
(cons width (* height dir))))
(if (> dir 0)
(cons (interval-start X-ext) (+ (interval-start Y-ext) 0.1))
(cons (interval-start X-ext) (+ (interval-start Y-ext)
height)))))
#f))
\relative c' {
\numericTimeSignature
\tempo 4=52
\override NoteHead.font-size = #-1.5
$(add-grace-property 'Voice 'NoteHead 'font-size -4.5)
\time 5/8
\override Score.GraceSpacing.spacing-increment = #7
\once \override Glissando #'bound-details =
#'((right (attach-dir . 0) (end-on-accidental . #f) (padding . 2.))
(left (attach-dir . 1) (padding . 0.)))
\once \override Glissando #'stencil = #path-gliss
#(set-arc 0 -4)
\grace b16\glissando
a''4.~->
\tuplet 5/4 { a16 gis fis, e'-> a,~ }
\time 3/8
}
<http://lilypond.1069038.n5.nabble.com/file/n177488/example2.png>
...which is very ok! But I would like (probably in other points of the score
I am working on) to have more flexibility to draw the four variables of the
curveto list, as I had with the arrowhead-less solution.
This let me to try making similar changes I did in the first version of the
code, adding third and fourth handles to the curveto list and deleting the
double zero of that line:
\version "2.18.2"
arc = #(list 0 0) %<< global variable to bezier curve handle
glissWidth = #0.2 %<< global variable for glissando width
#(define (set-arc x y)
(set! arc (list x y)))
#(define (get-arc)
arc)
#(define (radians->degrees theta)
(* theta (/ 180 PI)))
#(define (path-gliss grob)
(if (ly:stencil? (ly:line-spanner::print grob))
(let* ((stencil (ly:line-spanner::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(height (interval-length Y-ext))
(lefty (cdr (assoc 'Y (ly:grob-property grob
'left-bound-info))))
(righty (cdr (assoc 'Y (ly:grob-property grob
'right-bound-info))))
(deltay (- righty lefty))
(dir (if (> deltay 0) 1 -1))
(handle (get-arc))) ;<<------------- getting the
handle value here
(ly:stencil-translate
(ly:stencil-add
(grob-interpret-markup grob
(markup
;(#: tiny (format "~a" (ly:grob-properties grob)))
;(format "~a" (cdr (assoc 'Y (ly:grob-property grob
'left-bound-info))))
;(#: tiny (format "~a" handle))
(#:path glissWidth
(list (list 'moveto 0 0)
(list 'curveto (first handle)
(second handle) (third handle) (fourth handle) width (* height dir))))))
(ly:stencil-translate
; the \rotate markup command doesn't let us pick a rotation
center, so we resort to the stencil command
(ly:stencil-rotate
(grob-interpret-markup grob
(markup #:arrow-head X RIGHT #t))
(radians->degrees
($atan2
(- (* height dir) (fourth handle))
(- width (third handle)))) 1 0)
(cons width (* height dir))))
(if (> dir 0)
(cons (interval-start X-ext) (+ (interval-start Y-ext) 0.1))
(cons (interval-start X-ext) (+ (interval-start Y-ext)
height)))))
#f))
\relative c' {
\numericTimeSignature
\tempo 4=52
\override NoteHead.font-size = #-1.5
$(add-grace-property 'Voice 'NoteHead 'font-size -4.5)
\time 5/8
\override Score.GraceSpacing.spacing-increment = #7
\once \override Glissando #'bound-details =
#'((right (attach-dir . 0) (end-on-accidental . #f) (padding . 2.))
(left (attach-dir . 1) (padding . 0.)))
\once \override Glissando #'stencil = #path-gliss
#(set-arc 7 1 0 -4)
\grace b16\glissando
a''4.~->
\tuplet 5/4 { a16 gis fis, e'-> a,~ }
\time 3/8
}
This gave me the Error Log copied below:
*
Starting lilypond 2.18.2 [Untitled (2)]...*
Processing
`/var/folders/93/2hc4wy_x7ygf7rb7q181xfgm0000gn/T/frescobaldi-4di9Vd/tmpcv2O7y/document.ly'
Parsing...
/var/folders/93/2hc4wy_x7ygf7rb7q181xfgm0000gn/T/frescobaldi-4di9Vd/tmpcv2O7y/document.ly:75:10:
error: GUILE signaled an error for the expression beginning here
#
(set-arc 7 1 0 -4)
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...Wrong number of arguments to #<procedure set-arc (x y)>
/var/folders/93/2hc4wy_x7ygf7rb7q181xfgm0000gn/T/frescobaldi-4di9Vd/tmpcv2O7y/document.ly:39:90:
In procedure caddr in expression (third handle):
/var/folders/93/2hc4wy_x7ygf7rb7q181xfgm0000gn/T/frescobaldi-4di9Vd/tmpcv2O7y/document.ly:39:90:
Wrong type (expecting pair): ()
*Exited with return code 1.*
It's clear for me that the
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/how-to-create-lines-between-all-consecutive-notes-tp142126p177488.html
Sent from the User mailing list archive at Nabble.com.
- Re: override stencil question, priosfilho, 2015/06/04
- Re: override stencil question, Nathan Ho, 2015/06/04
- Re: override stencil question, priosfilho, 2015/06/04
- Re: override stencil question, Nathan Ho, 2015/06/04
- Re: override stencil question, priosfilho, 2015/06/04
- Re: override stencil question, Nathan Ho, 2015/06/04
- Re: override stencil question,
priosfilho <=
- Re: override stencil question, Nathan Ho, 2015/06/04
- Re: override stencil question, priosfilho, 2015/06/04