[latex3-commits] [latex3/latex3] main: Correct implementation of \draw_path_replace_bb: (46c6191f5)

github at latex-project.org github at latex-project.org
Fri Feb 23 16:30:10 CET 2024


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/46c6191f5f899f46087e6738348f233793c69ca3

>---------------------------------------------------------------

commit 46c6191f5f899f46087e6738348f233793c69ca3
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Feb 23 15:26:22 2024 +0000

    Correct implementation of \draw_path_replace_bb:


>---------------------------------------------------------------

46c6191f5f899f46087e6738348f233793c69ca3
 l3experimental/l3draw/l3draw-paths.dtx             | 37 ++++++++++++----------
 .../l3draw/testfiles/m3draw007.etex-dvips.tlg      | 37 ++++++++++++++++++++++
 .../l3draw/testfiles/m3draw007.etex-dvisvgm.tlg    | 32 +++++++++++++++++++
 l3experimental/l3draw/testfiles/m3draw007.lvt      | 14 ++++++++
 l3experimental/l3draw/testfiles/m3draw007.tlg      | 30 ++++++++++++++++++
 .../l3draw/testfiles/m3draw007.uptex.tlg           | 37 ++++++++++++++++++++++
 .../l3draw/testfiles/m3draw007.xetex.tlg           | 30 ++++++++++++++++++
 7 files changed, 201 insertions(+), 16 deletions(-)

diff --git a/l3experimental/l3draw/l3draw-paths.dtx b/l3experimental/l3draw/l3draw-paths.dtx
index 2d9a384b0..cd00e4a86 100644
--- a/l3experimental/l3draw/l3draw-paths.dtx
+++ b/l3experimental/l3draw/l3draw-paths.dtx
@@ -841,9 +841,10 @@
 %
 % \begin{macro}{\draw_path_use:n, \draw_path_use_clear:n}
 % \begin{macro}{\draw_path_replace_bb:}
+% \begin{macro}{\@@_path_replace_bb:NnN}
 % \begin{macro}{\@@_path_use:n}
 % \begin{macro}{\@@_path_use_action_draw:, \@@_path_use_action_fillstroke:}
-% \begin{macro}{\@@_path_use_bb:, \@@_path_use_stroke_bb:}  
+% \begin{macro}{\@@_path_use_stroke_bb:}  
 % \begin{macro}{\@@_path_use_bb:NnN}
 %   There are a range of actions which can apply to a path: they are handled
 %   in a single function which can carry out several of them. The first step
@@ -867,11 +868,21 @@
   }
 \cs_new_protected:Npn \draw_path_replace_bb:
   {
-    \@@_reset_bb:
-    \@@_path_use_bb:
+    \@@_path_replace_bb:NnN x { max } +
+    \@@_path_replace_bb:NnN y { max } +
+    \@@_path_replace_bb:NnN x { min } -
+    \@@_path_replace_bb:NnN y { min } -
     \@@_softpath_clear:
     \@@_path_reset_limits:
   }
+\cs_new_protected:Npn \@@_path_replace_bb:NnN #1#2#3
+  {
+    \dim_gset:cn { g_@@_ #1#2 _dim }
+      {
+          \dim_use:c { g_@@_path_ #1#2 _dim }
+        #3 0.5 \g_@@_linewidth_dim
+      }
+  }
 %    \end{macrocode}
 %   Map over the actions and set up the data: mainly just booleans,
 %   but with the possibility to cover more complex cases. The business end
@@ -938,21 +949,14 @@
 %   Where the path is relevant to size and is stroked, we need to allow for
 %   the part which overlaps the edge of the bounding box.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_path_use_bb:
-  {
-    \@@_path_use_bb:NnNN x { max } + 0
-    \@@_path_use_bb:NnNN y { max } + 0
-    \@@_path_use_bb:NnNN x { min } - 0
-    \@@_path_use_bb:NnNN y { min } - 0
-  }
 \cs_new_protected:Npn \@@_path_use_stroke_bb:
   {
-    \@@_path_use_bb:NnNN x { max } + 5
-    \@@_path_use_bb:NnNN y { max } + 5
-    \@@_path_use_bb:NnNN x { min } - 5
-    \@@_path_use_bb:NnNN y { min } - 5
+    \@@_path_use_bb:NnN x { max } +
+    \@@_path_use_bb:NnN y { max } +
+    \@@_path_use_bb:NnN x { min } -
+    \@@_path_use_bb:NnN y { min } -
   }
-\cs_new_protected:Npn \@@_path_use_bb:NnNN #1#2#3#4
+\cs_new_protected:Npn \@@_path_use_bb:NnN #1#2#3
   {
     \dim_compare:nNnF { \dim_use:c { g_@@_ #1#2 _dim } } = { #3 -\c_max_dim }
       {
@@ -962,7 +966,7 @@
               { \dim_use:c { g_@@_ #1#2 _dim } }
               {
                   \dim_use:c { g_@@_path_ #1#2 _dim }
-                #3 0.#4 \g_@@_linewidth_dim
+                #3 0.5 \g_@@_linewidth_dim
               } 
           }
       }
@@ -974,6 +978,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \subsection{Scoping paths}
 %
diff --git a/l3experimental/l3draw/testfiles/m3draw007.etex-dvips.tlg b/l3experimental/l3draw/testfiles/m3draw007.etex-dvips.tlg
index 6fc822629..fdd4e5508 100644
--- a/l3experimental/l3draw/testfiles/m3draw007.etex-dvips.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw007.etex-dvips.tlg
@@ -186,3 +186,40 @@ TEST 5: clip;fill
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Replace bb
+============================================================
+> \box...=
+\hbox(28.85275+0.0)x28.85275
+.\hbox(28.85275+0.0)x28.85275
+..\glue 14.42638
+..\hbox(0.0+0.0)x0.0, shifted -14.42638
+...\special{ps::[begin]}
+...\special{ps::@beginspecial}
+...\special{ps::0.39851 setlinewidth}
+...\special{color push gray 0}
+...\special{ps:SDict begin /color.sc {} def end}
+...\special{ps::0 setlinecap}
+...\special{ps::0 setlinejoin}
+...\special{ps::10 setmiterlimit}
+...\special{ps::[] 0 setdash}
+...\hbox(0.0+0.0)x0.0
+....\special{ps::35.43307 0 moveto}
+....\special{ps::35.43307 19.56915 19.56915 35.43307 0 35.43307 curveto}
+....\special{ps::-19.56915 35.43307 -35.43307 19.56915 -35.43307 0 curveto}
+....\special{ps::-35.43307 -19.56915 -19.56915 -35.43307 0 -35.43307 curveto}
+....\special{ps::19.56915 -35.43307 35.43307 -19.56915 35.43307 0 curveto}
+....\special{ps::closepath}
+....\special{ps::0 0 moveto}
+....\special{ps::gsave}
+....\special{ps::color.sc}
+....\special{ps::stroke}
+....\special{ps::grestore}
+....\special{ps::newpath}
+...\special{ps::@endspecial}
+...\special{ps::[end]}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw007.etex-dvisvgm.tlg b/l3experimental/l3draw/testfiles/m3draw007.etex-dvisvgm.tlg
index 7cc5bc4fb..80f061997 100644
--- a/l3experimental/l3draw/testfiles/m3draw007.etex-dvisvgm.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw007.etex-dvisvgm.tlg
@@ -173,3 +173,35 @@ TEST 5: clip;fill
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Replace bb
+============================================================
+> \box...=
+\hbox(28.85275+0.0)x28.85275
+.\hbox(28.85275+0.0)x28.85275
+..\glue 14.42638
+..\hbox(0.0+0.0)x0.0, shifted -14.42638
+...\special{dvisvgm:raw <g>{?nl}}
+...\special{dvisvgm:raw <g transform="translate({?x},{?y}) scale(1,-1)">{?nl}}
+...\special{dvisvgm:raw <g stroke-width="0.4">{?nl}}
+...\special{color push gray 0}
+...\special{dvisvgm:raw <g fill-rule="nonzero">{?nl}}
+...\special{dvisvgm:raw <g stroke-linecap="butt">{?nl}}
+...\special{dvisvgm:raw <g stroke-linejoin="miter">{?nl}}
+...\special{dvisvgm:raw <g stroke-miterlimit="10">{?nl}}
+...\special{dvisvgm:raw <g stroke-dasharray="none" stroke-offset="0">{?nl}}
+...\hbox(0.0+0.0)x0.0
+....\special{dvisvgm:raw <path d="M 35.56595 0 C 35.56595 19.64253 19.64253 35.56595 0 35.56595 C -19.64253 35.56595 -35.56595 19.64253 -35.56595 0 C -35.56595 -19.64253 -19.64253 -35.56595 0 -35.56595 C 19.64253 -35.56595 35.56595 -19.64253 35.56595 0 Z M 0 0" style="fill:none"/>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{dvisvgm:raw </g>{?nl}}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw007.lvt b/l3experimental/l3draw/testfiles/m3draw007.lvt
index 5df410682..5912816c1 100644
--- a/l3experimental/l3draw/testfiles/m3draw007.lvt
+++ b/l3experimental/l3draw/testfiles/m3draw007.lvt
@@ -80,4 +80,18 @@
     \test:nn { clip } { fill }
   }
 
+\TEST { Replace~bb }
+  {
+    \hbox_set:Nn \l_tmpa_box
+      {
+        \draw_begin:
+          \draw_path_circle:nn { 0 , 0 } { 1.25cm }
+          \draw_path_use_clear:n { stroke }
+          \draw_path_rectangle_corners:nn { -0.5cm , -0.5cm } { 0.5cm , 0.5cm }
+          \draw_path_replace_bb:
+        \draw_end:
+      }
+    \box_show:N \l_tmpa_box
+  }
+
 \END
diff --git a/l3experimental/l3draw/testfiles/m3draw007.tlg b/l3experimental/l3draw/testfiles/m3draw007.tlg
index feb294e84..623f89a74 100644
--- a/l3experimental/l3draw/testfiles/m3draw007.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw007.tlg
@@ -156,3 +156,33 @@ TEST 5: clip;fill
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Replace bb
+============================================================
+> \box...=
+\hbox(28.85275+0.0)x28.85275
+.\hbox(28.85275+0.0)x28.85275
+..\glue 14.42638
+..\hbox(0.0+0.0)x0.0, shifted -14.42638
+...\pdfsave
+...\pdfliteral{0.39851 w}
+...\pdfcolorstack 0 push {0 g 0 G}
+...\pdfliteral{0 J}
+...\pdfliteral{0 j}
+...\pdfliteral{10 M}
+...\pdfliteral{[] 0 d}
+...\hbox(0.0+0.0)x0.0
+....\pdfliteral{35.43307 0 m}
+....\pdfliteral{35.43307 19.56915 19.56915 35.43307 0 35.43307 c}
+....\pdfliteral{-19.56915 35.43307 -35.43307 19.56915 -35.43307 0 c}
+....\pdfliteral{-35.43307 -19.56915 -19.56915 -35.43307 0 -35.43307 c}
+....\pdfliteral{19.56915 -35.43307 35.43307 -19.56915 35.43307 0 c}
+....\pdfliteral{h}
+....\pdfliteral{0 0 m}
+....\pdfliteral{S}
+...\pdfrestore
+...\pdfcolorstack 0 pop
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw007.uptex.tlg b/l3experimental/l3draw/testfiles/m3draw007.uptex.tlg
index 6fc822629..fdd4e5508 100644
--- a/l3experimental/l3draw/testfiles/m3draw007.uptex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw007.uptex.tlg
@@ -186,3 +186,40 @@ TEST 5: clip;fill
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Replace bb
+============================================================
+> \box...=
+\hbox(28.85275+0.0)x28.85275
+.\hbox(28.85275+0.0)x28.85275
+..\glue 14.42638
+..\hbox(0.0+0.0)x0.0, shifted -14.42638
+...\special{ps::[begin]}
+...\special{ps::@beginspecial}
+...\special{ps::0.39851 setlinewidth}
+...\special{color push gray 0}
+...\special{ps:SDict begin /color.sc {} def end}
+...\special{ps::0 setlinecap}
+...\special{ps::0 setlinejoin}
+...\special{ps::10 setmiterlimit}
+...\special{ps::[] 0 setdash}
+...\hbox(0.0+0.0)x0.0
+....\special{ps::35.43307 0 moveto}
+....\special{ps::35.43307 19.56915 19.56915 35.43307 0 35.43307 curveto}
+....\special{ps::-19.56915 35.43307 -35.43307 19.56915 -35.43307 0 curveto}
+....\special{ps::-35.43307 -19.56915 -19.56915 -35.43307 0 -35.43307 curveto}
+....\special{ps::19.56915 -35.43307 35.43307 -19.56915 35.43307 0 curveto}
+....\special{ps::closepath}
+....\special{ps::0 0 moveto}
+....\special{ps::gsave}
+....\special{ps::color.sc}
+....\special{ps::stroke}
+....\special{ps::grestore}
+....\special{ps::newpath}
+...\special{ps::@endspecial}
+...\special{ps::[end]}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw007.xetex.tlg b/l3experimental/l3draw/testfiles/m3draw007.xetex.tlg
index 900372ca5..dd137b649 100644
--- a/l3experimental/l3draw/testfiles/m3draw007.xetex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw007.xetex.tlg
@@ -156,3 +156,33 @@ TEST 5: clip;fill
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Replace bb
+============================================================
+> \box...=
+\hbox(28.85275+0.0)x28.85275
+.\hbox(28.85275+0.0)x28.85275
+..\glue 14.42638
+..\hbox(0.0+0.0)x0.0, shifted -14.42638
+...\special{x:gsave}
+...\special{pdf:literal 0.39851 w}
+...\special{pdf:bc [0]}
+...\special{pdf:literal 0 J}
+...\special{pdf:literal 0 j}
+...\special{pdf:literal 10 M}
+...\special{pdf:literal [] 0 d}
+...\hbox(0.0+0.0)x0.0
+....\special{pdf:literal 35.43307 0 m}
+....\special{pdf:literal 35.43307 19.56915 19.56915 35.43307 0 35.43307 c}
+....\special{pdf:literal -19.56915 35.43307 -35.43307 19.56915 -35.43307 0 c}
+....\special{pdf:literal -35.43307 -19.56915 -19.56915 -35.43307 0 -35.43307 c}
+....\special{pdf:literal 19.56915 -35.43307 35.43307 -19.56915 35.43307 0 c}
+....\special{pdf:literal h}
+....\special{pdf:literal 0 0 m}
+....\special{pdf:literal S}
+...\special{x:grestore}
+...\special{pdf:ec}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.