[Top][All Lists]

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

Re: Refactor \markup \pattern (issue 549780045 by address@hidden)

From: dak
Subject: Re: Refactor \markup \pattern (issue 549780045 by address@hidden)
Date: Tue, 31 Mar 2020 15:17:01 -0700

Reviewers: hanwenn,
File scm/define-markup-commands.scm (right):
scm/define-markup-commands.scm:4636: (space (if (= axis X) space (* 3.0
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.
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.

Refactor \markup \pattern

Please review this at

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
--- 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 
   (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) 
          (x-offset (+ (* (- (- middle-width (* count period)) pattern-width) 
(/ (1+ dir) 2)) (abs (car pattern-x-extent)))))
     (interpret-markup layout props
                       (markup #:stencil left-stencil

reply via email to

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