[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Lilypond-auto] Issue 2752 in lilypond: Parenthesize dots in fretboa
From: |
lilypond |
Subject: |
Re: [Lilypond-auto] Issue 2752 in lilypond: Parenthesize dots in fretboards |
Date: |
Fri, 17 Aug 2012 09:34:17 +0000 |
Comment #1 on issue 2752 by address@hidden: Parenthesize dots in
fretboards
http://code.google.com/p/lilypond/issues/detail?id=2752
Thomas Morley posted a follow-up to point out that this is a popular
request on the German user's list, and also to offer an implementation.
From Thomas:
@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