[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
simplify previous patch-set by special casing 2-line staves (issue 65060
From: |
k-ohara5a5a |
Subject: |
simplify previous patch-set by special casing 2-line staves (issue 6506090) |
Date: |
Mon, 10 Sep 2012 07:07:26 +0000 |
This works, although in surprising ways.
It was a challenge for me to figure out why the tests in
'repeat-sign.ly' come out as they do. I was very surprised by the lines
marked "dots in outer spaces" and "dots outside" and assume we would
prefer more centered placement. The case "dots in outer spaces" is
different from a four-line staff in that the user indicates eight
scale-steps will fit between lines; if eight scale steps fit legibly,
two repeat dots will also fit.
You could simplify at this point, and work entirely in staff-positions,
until the end where you build the stencil. I also suggest using a rule
"prefer dots in tight spaces to dots completely outside the staff"
rather than the special case for 2-line staves.
(define (make-colon-bar-line grob)
(let* ((staff-symbol (get-staff-symbol grob))
(line-span (staff-symbol-line-span staff-symbol))
(center (interval-center line-span))
(line-pos (staff-symbol-line-positions staff-symbol))
;; Fold 'line-positions about its center
;; to look for symmetric locations for the dots
(folded-staff (sort (map (lambda (lp) (abs (- lp center)))
(cons center line-pos))
<))
(dist (or
;; Prefer dots in gaps of >1 staff-positions between
lines
(any (lambda (x y) (if (> (- x y) 1.2)
(+ x y)
#f))
(cdr folded-staff)
folded-staff)
;; ... but a gap of >0.5 staff-positions
(any (lambda (x y) (if (> (- x y) 0.6)
(+ x y)
#f))
(cdr folded-staff)
folded-staff)
;; ... is better than outside the staff
(+ 2 (interval-length line-span))))
(staff-space (ly:staff-symbol-staff-space grob))
(staff-space (if (> staff-space 0.0) staff-space 1.0))
(dot (ly:font-get-glyph (ly:grob-default-font grob)
"dots.dot"))
(stencil empty-stencil)
(stencil (ly:stencil-add stencil dot))
(stencil (ly:stencil-translate-axis
stencil (* dist (/ staff-space 2)) Y))
(stencil (ly:stencil-add stencil dot))
(stencil (ly:stencil-translate-axis
stencil (* (- center (/ dist 2))
(/ staff-space 2)) Y)))
stencil))
http://codereview.appspot.com/6506090/
- simplify previous patch-set by special casing 2-line staves (issue 6506090),
k-ohara5a5a <=