\version "2.23.0" \header { texidoc = "Dots in fret diagrams may be colored as well as the entire fret diagram. In the test below the fret diagram is printed with bigger dots and in landscape orientation if the dot-color is not the same as the color of the entire fret diagram. The fret diagrams should be printed in orientation: default, landscape, default, landscape." } #(define (lists-map function ls) "Apply @var{function} to @var{ls} and all of it sublists. First it recurses over the children, then the function is applied to @var{ls}." (if (list? ls) (set! ls (map (lambda (y) (lists-map function y)) ls)) ls) (function ls)) #(define-markup-command (dot-radius-from-color layout props arg)(markup?) "Returns increased sized dots for a fret diagram, if the color of the dot is different from the general color." ;; REMARK This is coding is pretty fragile and likely fails for more complex ;; examples (let* ((stil (interpret-markup layout props arg)) (stil-expr (ly:stencil-expr stil)) (circle-color #f) (general-color #f)) (lists-map (lambda (l) (if (and (list? l) (> (length l) 2) (eq? (car l) 'color)) (begin (if (and (list? (third l)) (eq? (car (third l)) 'circle)) (set! circle-color (cadr l)) (set! general-color (cadr l))) l) l)) stil-expr) ;; increase dot's radius in certain cases (interpret-markup layout props (cond ;; if dot-color is unset or dot-color is set and equal general color ;; return unchanged ((or (not circle-color) (equal? general-color circle-color)) arg) ;; if general color is unset and dot-color is unset or black ;; return unchanged ((and (not general-color) (or (not circle-color) (equal? circle-color '(0 0 0)))) arg) ;; if dot-color is not equal general color ;; increase the dot's radius (else (make-override-markup '(fret-diagram-details . ((dot-radius . 0.5) (orientation . landscape))) arg)))))) mrkp = \markup \column \override #'(padding . 2) \table #'(0 0 0 0) { "default" \center-column { "landscape" "big blue dot" } \center-column { "default" "default sized red dot" } \center-column { "landscape" "big blue dot" } \dot-radius-from-color { \fret-diagram-verbose #'((place-fret 1 1 1)) \fret-diagram-verbose #'((place-fret 1 1 1 blue)) \with-color #red { \fret-diagram-verbose #'((place-fret 1 1 1)) \fret-diagram-verbose #'((place-fret 1 1 1 blue)) } } } { f''^\mrkp }