[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3build: Rectangles (2404f7c)

Joseph Wright joseph.wright at morningstar2.co.uk
Sat Feb 17 23:38:30 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/2404f7c41f210e1826bbc6bca772bf17fed6e361

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

commit 2404f7c41f210e1826bbc6bca772bf17fed6e361
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sat Feb 17 22:22:20 2018 +0000

    l3build: Rectangles


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

2404f7c41f210e1826bbc6bca772bf17fed6e361
 l3trial/l3draw/l3draw-paths.dtx              |   54 ++++++++++++++++++++++++++
 l3trial/l3draw/l3draw-softpath.dtx           |   10 ++---
 l3trial/l3draw/l3draw.dtx                    |    7 ++++
 l3trial/l3draw/testfiles/m3draw003.lvt       |   23 +++++++++++
 l3trial/l3draw/testfiles/m3draw003.ptex.tlg  |   45 +++++++++++++++++++++
 l3trial/l3draw/testfiles/m3draw003.tlg       |   45 +++++++++++++++++++++
 l3trial/l3draw/testfiles/m3draw003.uptex.tlg |   45 +++++++++++++++++++++
 l3trial/l3draw/testfiles/m3draw003.xetex.tlg |   45 +++++++++++++++++++++
 8 files changed, 269 insertions(+), 5 deletions(-)

diff --git a/l3trial/l3draw/l3draw-paths.dtx b/l3trial/l3draw/l3draw-paths.dtx
index d54485e..1e5b1d1 100644
--- a/l3trial/l3draw/l3draw-paths.dtx
+++ b/l3trial/l3draw/l3draw-paths.dtx
@@ -672,6 +672,60 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{Rectangles}
+%
+% \begin{macro}{\draw_path_rectangle:nn}
+% \begin{macro}{\@@_path_rectangle:nnnn, \@@_path_rectangle_rounded:nnnn}
+%   Building a rectangle can be a single operation, or for rounded versions will
+%   involve step-by-step construction.
+%    \begin{macrocode}
+\cs_new_protected:Npn \draw_path_rectangle:nn #1#2
+  {
+    \@@_point_process:nnn
+      {
+        \bool_if:NTF \l_@@_corner_arc_bool
+          { \@@_path_rectangle_rounded:nnnn }
+          { \@@_path_rectangle:nnnn }
+      }
+      { \draw_point_transform:n {#1} }
+      {#2}
+  }
+\cs_new_protected:Npn \@@_path_rectangle:nnnn #1#2#3#4
+  {
+    \@@_path_update_limits:nn {#1} {#2}
+    \@@_path_update_limits:nn { #1 + #3 } { #2 + #4 }
+    \@@_softpath_rectangle:nnnn {#1} {#2} {#3} {#4}
+    \@@_path_update_last:nn {#1} {#2}
+  }
+\cs_new_protected:Npn \@@_path_rectangle_rounded:nnnn #1#2#3#4
+  {
+    \draw_path_moveto:n { #1 + #3 , #2 + #4 }
+    \draw_path_lineto:n { #1 , #2 + #4 }
+    \draw_path_lineto:n { #1 , #2 }
+    \draw_path_lineto:n { #1 + #3 , #2 }
+    \draw_path_close:
+    \draw_path_moveto:n { #1 , #2 }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\draw_path_rectangle_corners:nn}
+% \begin{macro}{\@@_path_rectangle_corners:nnnn}
+%   Another shortcut wrapper.
+%    \begin{macrocode}
+\cs_new_protected:Npn \draw_path_rectangle_corners:nn #1#2
+  {
+    \@@_point_process:nnn
+      { \@@_path_rectangle_corners:nnnnn {#1} }
+      {#1} {#2}
+  }
+\cs_new_protected:Npn \@@_path_rectangle_corners:nnnnn #1#2#3#4#5
+  { \draw_path_rectangle:nn {#1} { #4 - #2 , #5 - #3 } }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3trial/l3draw/l3draw-softpath.dtx b/l3trial/l3draw/l3draw-softpath.dtx
index 316423a..1601112 100644
--- a/l3trial/l3draw/l3draw-softpath.dtx
+++ b/l3trial/l3draw/l3draw-softpath.dtx
@@ -253,7 +253,7 @@
         \dim_gset:Nn \g_@@_softpath_lasty_dim {#2}
       }
   }
-\cs_new_protected:Npn \@@_softpath_rectangle:nn #1#2#3#4
+\cs_new_protected:Npn \@@_softpath_rectangle:nnnn #1#2#3#4
   {
     \@@_softpath_add:n
       {
@@ -264,7 +264,7 @@
 \cs_new_protected:Npn \@@_softpath_roundpoint:nn #1#2
   {
     \@@_softpath_add:n
-      { \@@_softpath_round_op:nn {#1} {#2} }
+      { \@@_softpath_roundpoint_op:nn {#1} {#2} }
   }
 \cs_generate_variant:Nn \@@_softpath_roundpoint:nn { VV }
 %    \end{macrocode}
@@ -283,7 +283,7 @@
 %     \@@_softpath_rectangle_opii:nn
 %   }
 % \begin{macro}{\@@_softpath_curveto_opi:nnNnnNnn}
-% \begin{macro}{\@@_softpath_curveto_opi:nnNnn}
+% \begin{macro}{\@@_softpath_rectangle_opi:nnNnn}
 %   The markers for operations: all the top-level ones take two arguments.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_softpath_close_op:nn #1#2
@@ -300,8 +300,8 @@
   { \driver_draw_moveto:nn {#1} {#2} }
 \cs_new_protected:Npn \@@_softpath_roundpoint_op:nn #1#2 { }
 \cs_new_protected:Npn \@@_softpath_rectangle_opi:nn #1#2 
-  { \@@_softpath_rectangle_opi:nnNnn{#1} {#2} }
-\cs_new_protected:Npn \@@_softpath_rectangle_opi:nnNnnNnn #1#2#3#4#5
+  { \@@_softpath_rectangle_opi:nnNnn {#1} {#2} }
+\cs_new_protected:Npn \@@_softpath_rectangle_opi:nnNnn #1#2#3#4#5
   { \driver_draw_rectangle:nnnn {#1} {#2} {#4} {#5} }
   \cs_new_protected:Npn \@@_softpath_rectangle_opii:nn #1#2 { }
 %    \end{macrocode}
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index 6cdcea8..9054857 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -275,6 +275,13 @@
 %   \end{syntax}
 % \end{function}
 %
+% \begin{function}{\draw_path_rectangle:nn, \draw_path_rectangle_corners:nn}
+%   \begin{syntax}
+%     \cs{draw_path_rectangle:nn} \Arg{lower-left} \Arg{displacement}
+%     \cs{draw_path_rectangle_corners:nn} \Arg{lower-left} \Arg{top-right}
+%   \end{syntax}
+% \end{function}
+%
 % \begin{function}{\draw_path_close:}
 %   \begin{syntax}
 %     \cs{draw_path_close:}
diff --git a/l3trial/l3draw/testfiles/m3draw003.lvt b/l3trial/l3draw/testfiles/m3draw003.lvt
index 65e082c..9b2fb23 100644
--- a/l3trial/l3draw/testfiles/m3draw003.lvt
+++ b/l3trial/l3draw/testfiles/m3draw003.lvt
@@ -153,4 +153,27 @@
       }
   }
 
+\TEST { \draw_path_rectangle:nn }
+  {
+    \test:n
+      {
+        \draw_path_rectangle:nn
+          { \draw_point_vec:nn { 2 } { 2 } }
+          { \draw_point_vec:nn { 1 } { 1 } }
+      }
+    \test:n
+      {
+        \draw_path_corner_arc:n { 2pt , 2pt }
+        \draw_path_rectangle:nn
+          { \draw_point_vec:nn { 2 } { 2 } }
+          { \draw_point_vec:nn { 1 } { 1 } }
+      }
+    \test:n
+      {
+        \draw_path_rectangle_corners:nn
+          { \draw_point_vec:nn { 2 } { 2 } }
+          { \draw_point_vec:nn { 3 } { 3 } }
+      }
+  }
+
 \END
diff --git a/l3trial/l3draw/testfiles/m3draw003.ptex.tlg b/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
index 81de56f..44ebf47 100644
--- a/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
@@ -295,3 +295,48 @@ TEST 9: \draw_path_circle:nn
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 10: \draw_path_rectangle:nn 
+============================================================
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 56.69292 56.69292 28.34647 28.34647 re}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 85.03938 85.03938 m}
+...\special{pdf:literal 56.69292 85.03938 l}
+...\special{pdf:literal 56.69292 56.69292 l}
+...\special{pdf:literal 85.03938 56.69292 l}
+...\special{pdf:literal h}
+...\special{pdf:literal 56.69292 56.69292 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 56.69292 56.69292 28.34647 28.34647 re}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3trial/l3draw/testfiles/m3draw003.tlg b/l3trial/l3draw/testfiles/m3draw003.tlg
index 234920e..1ac3c11 100644
--- a/l3trial/l3draw/testfiles/m3draw003.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.tlg
@@ -295,3 +295,48 @@ TEST 9: \draw_path_circle:nn
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 10: \draw_path_rectangle:nn 
+============================================================
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{56.69292 56.69292 28.34647 28.34647 re}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{85.03938 85.03938 m}
+...\pdfliteral{56.69292 85.03938 l}
+...\pdfliteral{56.69292 56.69292 l}
+...\pdfliteral{85.03938 56.69292 l}
+...\pdfliteral{h}
+...\pdfliteral{56.69292 56.69292 m}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{56.69292 56.69292 28.34647 28.34647 re}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3trial/l3draw/testfiles/m3draw003.uptex.tlg b/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
index 81de56f..44ebf47 100644
--- a/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
@@ -295,3 +295,48 @@ TEST 9: \draw_path_circle:nn
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 10: \draw_path_rectangle:nn 
+============================================================
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 56.69292 56.69292 28.34647 28.34647 re}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 85.03938 85.03938 m}
+...\special{pdf:literal 56.69292 85.03938 l}
+...\special{pdf:literal 56.69292 56.69292 l}
+...\special{pdf:literal 85.03938 56.69292 l}
+...\special{pdf:literal h}
+...\special{pdf:literal 56.69292 56.69292 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 56.69292 56.69292 28.34647 28.34647 re}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3trial/l3draw/testfiles/m3draw003.xetex.tlg b/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
index 81de56f..44ebf47 100644
--- a/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
@@ -295,3 +295,48 @@ TEST 9: \draw_path_circle:nn
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 10: \draw_path_rectangle:nn 
+============================================================
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 56.69292 56.69292 28.34647 28.34647 re}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 85.03938 85.03938 m}
+...\special{pdf:literal 56.69292 85.03938 l}
+...\special{pdf:literal 56.69292 56.69292 l}
+...\special{pdf:literal 85.03938 56.69292 l}
+...\special{pdf:literal h}
+...\special{pdf:literal 56.69292 56.69292 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(142.2638+0.0)x28.45276
+.\hbox(142.2638+0.0)x28.45276
+..\glue -56.90552
+..\hbox(0.0+0.0)x0.0, shifted 56.90552
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 56.69292 56.69292 28.34647 28.34647 re}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================





More information about the latex3-commits mailing list