bug-lilypond
[Top][All Lists]
Advanced

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

\path markup command computes incorrect extents when using rmoveto after


From: Aaron Hill
Subject: \path markup command computes incorrect extents when using rmoveto after closepath
Date: Sun, 19 Jan 2020 22:20:36 -0800
User-agent: Roundcube Webmail/1.3.8

The logic within the \path markup command ignores the effect of closepath when converting relative coordinates to absolute ones. closepath moves the pen back to the starting point of the path. Relative coordinates are based on the current pen position, not the most recently specified point. When rmoveto is used after closepath, the value of current-point will be incorrect.

Here is an example showing the problem:

%%%%
\version "2.19.83"

% Here is the expected result (using moveto):
\markup \box \path #0.1 #'(
  (moveto 2 3) (rlineto 1 1) (rlineto 0 -1) (closepath)
  (moveto 3.5 3) (rlineto 1 1) (rlineto -1 0) (closepath))

% Here is the actual result (using rmoveto):
\markup \box \path #0.1 #'(
  (moveto 2 3) (rlineto 1 1) (rlineto 0 -1) (closepath)
  (rmoveto 1.5 0) (rlineto 1 1) (rlineto -1 0) (closepath))

% Here is a picture of what \path *thinks* is going on:
\markup \box \overlay {
  \path #0.1 #'(
    (moveto 2 3) (rlineto 1 1) (rlineto 0 -1) (closepath)
    (rmoveto 1.5 0) (rlineto 1 1) (rlineto -1 0) (closepath))
  \with-color #red \path #0.1 #'(
    (moveto 4.5 3) (rlineto 1 1) (rlineto -1 0) (closepath))
}
%%%%

The following patch seems to address the issue:

====
--- define-markup-commands.scm.bak 2020-01-19 22:09:02.904948800 -0800
+++ define-markup-commands.scm  2020-01-19 22:13:20.858573300 -0800
@@ -1179,8 +1179,15 @@
 }
 @end lilypond"
   (let* ((half-thickness (/ thickness 2))
+         (start-point '())
          (current-point '(0 . 0))
-         (set-point (lambda (lst) (set! current-point lst)))
+         (set-point (lambda (lst)
+                       (if (null? start-point)
+                         (set! start-point lst))
+                       (set! current-point lst)))
+         (reset-point (lambda ()
+                        (set! current-point start-point)
+                        (set! start-point '())))
          (relative? (lambda (x)
                       (string-prefix? "r" (symbol->string (car x)))))
          ;; For calculating extents, we want to modify the command
@@ -1224,7 +1231,7 @@
                                 (drop x 1))
                                ;; keep closepath for filtering;
                                ;; see `without-closepath'.
-                               (else x)))
+                               (else (reset-point) x)))
                             commands))
          ;; path-min-max does not accept 0-arg lists,
          ;; and since closepath does not affect extents, filter
====


-- Aaron Hill

Attachment: path-bounding-bug.cropped.png
Description: PNG image


reply via email to

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