[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: Mark corners in paths (94d4308)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Feb 14 23:28:43 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/94d4308d582bd597b424fe0aca9756ec138bd096

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

commit 94d4308d582bd597b424fe0aca9756ec138bd096
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Feb 14 22:28:43 2018 +0000

    l3draw: Mark corners in paths
    
    This will eventually allow corners to be rounded:
    needs the 'use a path' code.


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

94d4308d582bd597b424fe0aca9756ec138bd096
 l3trial/l3draw/l3draw-paths.dtx        |   69 +++++++++++++++++++++++++++++++-
 l3trial/l3draw/l3draw-softpath.dtx     |    3 +-
 l3trial/l3draw/l3draw.dtx              |    6 +++
 l3trial/l3draw/testfiles/m3draw000.tlg |   32 +++++++++++++++
 4 files changed, 107 insertions(+), 3 deletions(-)

diff --git a/l3trial/l3draw/l3draw-paths.dtx b/l3trial/l3draw/l3draw-paths.dtx
index 3785d2d..3841ac7 100644
--- a/l3trial/l3draw/l3draw-paths.dtx
+++ b/l3trial/l3draw/l3draw-paths.dtx
@@ -134,6 +134,66 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{Corner arcs}
+%
+% At the level of path \emph{construction}, rounded corners are handled
+% by inserting a marker into the path: that is then picked up once the
+% full path is constructed. Thus we need to set up the appropriate
+% data structures here, such that this can be applied every time it is
+% relevant.
+%
+% \begin{variable}{\l_@@_corner_xarc_dim, \l_@@_corner_yarc_dim}
+%   The two arcs in use.
+%    \begin{macrocode}
+\dim_new:N \l_@@_corner_xarc_dim
+\dim_new:N \l_@@_corner_yarc_dim
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\l_@@_corner_arc_bool}
+%   A flag to speed up the repeated checks.
+%    \begin{macrocode}
+\bool_new:N \l_@@_corner_arc_bool
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\draw_path_corner_arc:n}
+% \begin{macro}{\@@_path_mark_corner:nn}
+%   Calculate the arcs, check they are non-zero.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_path_mark_corner:nn
+  {
+    \@@_point_process:nn { \@@_path_moveto:nn } {#1}
+  }
+\cs_new_protected:Npn \@@_path_mark_corner:nn #1#2
+  {
+    \dim_set:Nn \l_@@_corner_xarc_dim {#1}
+    \dim_set:Nn \l_@@_corner_yarc_dim {#2}
+    \bool_lazy_and:nnTF
+      { \dim_compare_p:nNn \l_@@_corner_xarc_dim = { 0pt } }
+      { \dim_compare_p:nNn \l_@@_corner_yarc_dim = { 0pt } }
+      { \bool_set_false:N \l_@@_corner_arc_bool }
+      { \bool_set_true:N \l_@@_corner_arc_bool }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@@_path_mark_corner:}
+%   Mark up corners for arc post-processing.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_path_mark_corner:
+  {
+    \bool_if:NT \l_@@_corner_arc_bool
+      {
+        \@@_softpath_roundpoint:VV
+          \l_@@_corner_xarc_dim
+          \l_@@_corner_yarc_dim
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Basic path constructions}
 %
 % \begin{macro}{\draw_path_moveto:n, \draw_path_lineto:n}
@@ -164,6 +224,7 @@
 \cs_new_protected:Npn \@@_path_lineto:nn #1#2
   {
      \@@_path_update_limits:nn {#1} {#2}
+     \@@_path_mark_corner:
      \@@_softpath_lineto:nn {#1} {#2}
      \@@_path_update_last:nn {#1} {#2}
   }
@@ -183,6 +244,7 @@
      \@@_path_update_limits:nn {#1} {#2}
      \@@_path_update_limits:nn {#3} {#4}
      \@@_path_update_limits:nn {#5} {#6}
+     \@@_path_mark_corner:
      \@@_softpath_curveto:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6}
      \@@_path_update_last:nn {#5} {#6}
   }
@@ -193,10 +255,13 @@
 % \end{macro}
 %
 % \begin{macro}{\draw_path_close:}
-%   A simple wrapper (though will need curved corer support).
+%   A simple wrapper.
 %    \begin{macrocode}
 \cs_new_protected:Npn \draw_path_close:
-  { \@@_softpath_closepath: }
+  {
+    \@@_path_mark_corner:
+    \@@_softpath_closepath:
+  }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3trial/l3draw/l3draw-softpath.dtx b/l3trial/l3draw/l3draw-softpath.dtx
index f17f936..316423a 100644
--- a/l3trial/l3draw/l3draw-softpath.dtx
+++ b/l3trial/l3draw/l3draw-softpath.dtx
@@ -216,7 +216,7 @@
 %     \@@_softpath_moveto:nn
 %   }
 % \begin{macro}{\@@_softpath_rectangle:nnnn}
-% \begin{macro}{\@@_softpath_roundpoint:nn}
+% \begin{macro}{\@@_softpath_roundpoint:nn, \@@_softpath_roundpoint:VV}
 %   The various parts of a path expressed as the appropriate soft path
 %   functions.
 %    \begin{macrocode}
@@ -266,6 +266,7 @@
     \@@_softpath_add:n
       { \@@_softpath_round_op:nn {#1} {#2} }
   }
+\cs_generate_variant:Nn \@@_softpath_roundpoint:nn { VV }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index 82b7db5..4f2f9dc 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -215,6 +215,12 @@
 %
 % \subsection{Paths}
 %
+% \begin{function}{\draw_path_corner_arc:n}
+%   \begin{syntax}
+%     \cs{draw_path_corner_arc:n} \Arg{point expr}
+%   \end{syntax}
+% \end{function}
+%
 % \begin{function}{\draw_path_moveto:n}
 %   \begin{syntax}
 %     \cs{draw_path_moveto:n} \Arg{point expr}
diff --git a/l3trial/l3draw/testfiles/m3draw000.tlg b/l3trial/l3draw/testfiles/m3draw000.tlg
index 7ea0839..2d230e2 100644
--- a/l3trial/l3draw/testfiles/m3draw000.tlg
+++ b/l3trial/l3draw/testfiles/m3draw000.tlg
@@ -8,6 +8,38 @@ Author: Joseph Wright
 \g__draw_path_xmin_dim=\dimen...
 \g__draw_path_ymax_dim=\dimen...
 \g__draw_path_ymin_dim=\dimen...
+\l__draw_corner_xarc_dim=\dimen...
+\l__draw_corner_yarc_dim=\dimen...
+! Illegal parameter number in definition of \__draw_path_mark_corner:nn.
+<to be read again> 
+                   1
+l. ......_process:nn { \__draw_path_moveto:nn } {#1
+                                                  }
+You meant to type ## instead of #, right?
+Or maybe a } was forgotten somewhere earlier, and things
+are all screwed up? I'm going to assume that you meant ##.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/command-already-defined"
+! 
+! Control sequence \__draw_path_mark_corner:nn already defined.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ......_protected:Npn \__draw_path_mark_corner:nn
+                                                   #1#2
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| LaTeX has been asked to create a new control sequence
+| '\__draw_path_mark_corner:nn' but this name has already been used elsewhere.
+| 
+| The current meaning is:
+|   \protected\long macro:->\__draw_point_process:nn {\__draw_path_moveto:nn
+| }{##1}
+|...............................................
 \l__draw_xvec_x_dim=\dimen...
 \l__draw_xvec_y_dim=\dimen...
 \l__draw_yvec_x_dim=\dimen...





More information about the latex3-commits mailing list