Reviewers: hanwenn,
https://codereview.appspot.com/549780045/diff/555530045/scm/define-markup-commands.scm File scm/define-markup-commands.scm (right): https://codereview.appspot.com/549780045/diff/555530045/scm/define-markup-commands.scm#newcode4636 scm/define-markup-commands.scm:4636: (space (if (= axis X) space (* 3.0 space)))) On 2020/03/31 20:22:35, hanwenn wrote: > why 3.0 ? add a comment. vspace has a factor of 3 for its spacing. Will do. https://codereview.appspot.com/549780045/diff/555530045/scm/define-markup-commands.scm#newcode4675 scm/define-markup-commands.scm:4675: (count (inexact->exact (truncate (/ (- middle-width pattern-width) period)))) On 2020/03/31 20:22:35, hanwenn wrote: > unrelated change? Prerequisite. The previous version of \pattern was coded in a manner where it accepted unexact integers which does not make sense. But our predicates don't catch that even where warranted and a lot of code will bomb out on inexact integers late. Fixing the specific problem here for now made most sense and would have been required anyway if the predicates had been made more stringent. And since it should have been like this in the first place for obvious reasons, adding a comment here did not make a lot of sense, either. Description: Refactor \markup \pattern Please review this at https://codereview.appspot.com/549780045/ Affected files (+4, -20 lines): M scm/define-markup-commands.scm Index: scm/define-markup-commands.scm diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 8a9cf25cedeb8470092c6a43d4c62cd6045797e7..9dedd024b4a115c79ecae95a044d5d2f7d40cacb 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -4615,11 +4615,8 @@ Negative values may be used to produce mirror images. ;; Repeating ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TODO: this should really be pieced together at stencil level rather -;; than markup level - (define-markup-command (pattern layout props count axis space pattern) - (integer? integer? number? markup?) + (index? index? number? markup?) #:category other " Prints @var{count} times a @var{pattern} markup. @@ -4636,21 +4633,8 @@ Patterns are distributed on @var{axis}. } @end lilypond" (let* ((pattern-stencil (interpret-markup layout props pattern)) - (pattern-width (interval-length - (ly:stencil-extent pattern-stencil X))) - (new-props (prepend-alist-chain 'word-space 0 (prepend-alist-chain 'baseline-skip 0 props)))) - (let loop ((i (1- count)) (patterns (markup))) - (if (zero? i) - (interpret-markup - layout - new-props - (if (= axis X) - (markup patterns #:stencil pattern-stencil) - (markup #:column (patterns #:stencil pattern-stencil)))) - (loop (1- i) - (if (= axis X) - (markup patterns #:stencil pattern-stencil #:hspace space) - (markup #:column (patterns #:stencil pattern-stencil #:vspace space)))))))) + (space (if (= axis X) space (* 3.0 space)))) + (stack-stencils axis 1 space (make-list count pattern-stencil)))) (define-markup-command (fill-with-pattern layout props space dir pattern left right) (number? ly:dir? markup? markup? markup?) @@ -4688,7 +4672,7 @@ Patterns are aligned to the @var{dir} markup. (right-width (interval-length (ly:stencil-extent right-stencil X))) (middle-width (max 0 (- line-width (+ (+ left-width right-width) (* word-space 2))))) (period (+ space pattern-width)) - (count (truncate (/ (- middle-width pattern-width) period))) + (count (inexact->exact (truncate (/ (- middle-width pattern-width) period)))) (x-offset (+ (* (- (- middle-width (* count period)) pattern-width) (/ (1+ dir) 2)) (abs (car pattern-x-extent))))) (interpret-markup layout props (markup #:stencil left-stencil