bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parenthesize dots in fretboards


From: Thomas Morley
Subject: Re: parenthesize dots in fretboards
Date: Fri, 10 Aug 2012 14:16:43 +0200

2012/8/8 Mathew Lindner <address@hidden>:
> Hello,
>
> I look for the function to parenthesize dots in fretboards. How can I do that?
>
>
> \version "2.14.1"
>
> \relative c {
> d'^\markup { { {
> \fret-diagram-verbose #'((place-fret 3 4 1) )
>         } } } }
>
>
> Thank you very much
> Mathew
>
>
> _______________________________________________
> bug-lilypond mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-lilypond

@bug-squad

This is a feature-request coming out of a discussion in the German
LilyPond Forum.

There I suggested to change the `draw-dots'-definition (being part of
the 'make-fret-diagram'-definition to:

     (define (draw-dots dot-list)
       "Make dots for fret diagram."

       (let* ( (scale-dot-radius (* size dot-radius))
              (scale-dot-thick (* size th))
              (default-dot-color (assoc-get 'dot-color details 'black))
              (finger-label-padding 0.3)
              (dot-label-font-mag
                (* scale-dot-radius
                   (assoc-get 'dot-label-font-mag details 1.0)))
              (string-label-font-mag
                (* size
                   (assoc-get
                     'string-label-font-mag details
                     (cond ((or (eq? orientation 'landscape)
                                (eq? orientation 'opposing-landscape))
                            0.5)
                           (else  0.6)))))
              (mypair (car dot-list))
              (restlist (cdr dot-list))
              (string (car mypair))
              (fret (cadr mypair))
              (fret-coordinate (* size (+ (1- fret) dot-position)))
              (string-coordinate (* size (- string-count string)))
              (dot-coordinates
                (stencil-coordinates fret-coordinate string-coordinate))
              (extent (cons (- scale-dot-radius) scale-dot-radius))
              (finger (caddr mypair))
              (finger (if (number? finger) (number->string finger) finger))
              (inverted-color (eq? 'inverted (cadddr mypair)))
              (parenthesize? (eq? 'parenthesize (car (last-pair mypair))))
              (dot-color (if (or (and (eq? default-dot-color 'black)
inverted-color)
                                 (and (eq? default-dot-color 'white)
(not inverted-color)))
                             'white
                             'black))
              (dot-stencil-orig (if (eq? dot-color 'white)
                             (ly:stencil-add
                               (make-circle-stencil
                                 scale-dot-radius scale-dot-thick #t)
                               (ly:stencil-in-color
                                 (make-circle-stencil
                                   (- scale-dot-radius (* 0.5 scale-dot-thick))
                                   0  #t)
                                 1 1 1))
                             (make-circle-stencil
                               scale-dot-radius scale-dot-thick #t)))
              (par-dot-stencil (parenthesize-stencil
                                     dot-stencil-orig (/ scale-dot-thick
2) 0.2 1 (/ scale-dot-thick 2)))
              (dot-stencil (if parenthesize?
                             (let ((orig-length (interval-length
(ly:stencil-extent dot-stencil-orig X)))
                                   (par-length (interval-length
(ly:stencil-extent par-dot-stencil X)))
                                   )
                             (ly:stencil-translate-axis
                                     par-dot-stencil
                                       (- orig-length par-length (*
scale-dot-thick 1.5)) X))
                              dot-stencil-orig))
              (positioned-dot
                (ly:stencil-translate dot-stencil dot-coordinates))
              (labeled-dot-stencil
                (cond
                  ((or (eq? finger '())(eq? finger-code 'none))
                   positioned-dot)
                  ((eq? finger-code 'in-dot)
                   (let ((finger-label
                           (centered-stencil
                             (sans-serif-stencil
                               layout props dot-label-font-mag finger))))
                     (ly:stencil-translate
                       (ly:stencil-add
                         dot-stencil
                         (if (eq? dot-color 'white)
                           finger-label
                           (ly:stencil-in-color finger-label 1 1 1)))
                       dot-coordinates)))
                  ((eq? finger-code 'below-string)
                   (let* ((label-stencil
                            (centered-stencil
                              (sans-serif-stencil
                                layout props string-label-font-mag
                                finger)))
                          (label-fret-offset
                            (stencil-fretboard-offset
                              label-stencil 'fret orientation))
                          (label-fret-coordinate
                            (+ (* size
                                  (+ 1 my-fret-count finger-label-padding))
                               label-fret-offset))
                          (label-string-coordinate string-coordinate)
                          (label-translation
                            (stencil-coordinates
                              label-fret-coordinate
                              label-string-coordinate)))
                     (ly:stencil-add
                       positioned-dot
                       (ly:stencil-translate
                         label-stencil
                         label-translation))))
                  (else ;unknown finger-code
                    positioned-dot))))
         (if (null? restlist)
           labeled-dot-stencil
           (ly:stencil-add
             (draw-dots restlist)
             labeled-dot-stencil))))


(and to convert the whole file into an .ly-file, which could be
included. Of course there would be no need for that, if it is part of
the source-could)

Please note that this is only a first shot. I'm not convinced about
it, because of the needed stencil-translation and the value of that
translation.

-Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]