[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add path scoping (6749d91)
Joseph Wright
joseph.wright at morningstar2.co.uk
Tue Feb 27 09:30:45 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/6749d9100b70102856b21ef8ea17a3a27a98cd32
>---------------------------------------------------------------
commit 6749d9100b70102856b21ef8ea17a3a27a98cd32
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Feb 27 08:30:45 2018 +0000
Add path scoping
The name here could be \draw_path_scope_begin: - that might make sense
but other types of scope don't have a 'family' of commands to sit
within. Need to see how this looks in the wider scheme.
>---------------------------------------------------------------
6749d9100b70102856b21ef8ea17a3a27a98cd32
l3experimental/l3draw/l3draw-scopes.dtx | 67 +++++++++++++++++++++++++
l3experimental/l3draw/l3draw.dtx | 14 +++++-
l3experimental/l3draw/testfiles/m3draw000.tlg | 8 +++
3 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/l3experimental/l3draw/l3draw-scopes.dtx b/l3experimental/l3draw/l3draw-scopes.dtx
index e006f98..e2b6ef7 100644
--- a/l3experimental/l3draw/l3draw-scopes.dtx
+++ b/l3experimental/l3draw/l3draw-scopes.dtx
@@ -235,6 +235,73 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{variable}
+% {
+% \l_@@_path_lastx_dim, \l_@@_path_lasty_dim,
+% \l_@@_path_xmax_dim, \l_@@_path_xmin_dim,
+% \l_@@_path_ymax_dim, \l_@@_path_ymin_dim
+% }
+% \begin{variable}{\l_@@_softpath_corners_bool}
+% Local storage for global data. There is already a
+% \cs{l_@@_softpath_main_tl} for path manipulation, so we can reuse that
+% (it is always grouped when the path is being reconstructed).
+% \begin{macrocode}
+\dim_new:N \l_@@_path_lastx_dim
+\dim_new:N \l_@@_path_lasty_dim
+\dim_new:N \l_@@_path_xmax_dim
+\dim_new:N \l_@@_path_xmin_dim
+\dim_new:N \l_@@_path_ymax_dim
+\dim_new:N \l_@@_path_ymin_dim
+\dim_new:N \l_@@_softpath_lastx_dim
+\dim_new:N \l_@@_softpath_lasty_dim
+\bool_new:N \l_@@_softpath_corners_bool
+% \end{macrocode}
+% \end{variable}
+% \end{variable}
+%
+% \begin{macro}{\draw_scope_path_begin:, \draw_scope_path_end:}
+% Scoping a path is a bit more involved, largely as there are a number
+% of variables to keep hold of.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_scope_path_begin:
+ {
+ \group_begin:
+ \dim_set_eq:NN \l_@@_path_lastx_dim \g_@@_path_lastx_dim
+ \dim_set_eq:NN \l_@@_path_lasty_dim \g_@@_path_lasty_dim
+ \dim_set_eq:NN \l_@@_path_xmax_dim \g_@@_path_xmax_dim
+ \dim_set_eq:NN \l_@@_path_xmin_dim \g_@@_path_xmin_dim
+ \dim_set_eq:NN \l_@@_path_ymax_dim \g_@@_path_ymax_dim
+ \dim_set_eq:NN \l_@@_path_ymin_dim \g_@@_path_ymin_dim
+ \dim_set_eq:NN \l_@@_softpath_lastx_dim \g_@@_softpath_lastx_dim
+ \dim_set_eq:NN \l_@@_softpath_lasty_dim \g_@@_softpath_lasty_dim
+ \@@_path_reset_limits:
+ \@@_softpath_concat:n { }
+ \tl_set_eq:NN \l_@@_softpath_main_tl \g_@@_softpath_main_tl
+ \bool_set_eq:NN
+ \l_@@_softpath_corners_bool
+ \g_@@_softpath_corners_bool
+ \@@_softpath_clear:
+ }
+\cs_new_protected:Npn \draw_scope_path_end:
+ {
+ \bool_gset_eq:NN
+ \g_@@_softpath_corners_bool
+ \l_@@_softpath_corners_bool
+ \@@_softpath_clear:
+ \tl_gset_eq:NN \g_@@_softpath_main_tl \l_@@_softpath_main_tl
+ \dim_gset_eq:NN \g_@@_softpath_lastx_dim \l_@@_softpath_lastx_dim
+ \dim_gset_eq:NN \g_@@_softpath_lasty_dim \l_@@_softpath_lasty_dim
+ \dim_gset_eq:NN \g_@@_path_xmax_dim \l_@@_path_xmax_dim
+ \dim_gset_eq:NN \g_@@_path_xmin_dim \l_@@_path_xmin_dim
+ \dim_gset_eq:NN \g_@@_path_ymax_dim \l_@@_path_ymax_dim
+ \dim_gset_eq:NN \g_@@_path_ymin_dim \l_@@_path_ymin_dim
+ \dim_gset_eq:NN \g_@@_path_lastx_dim \l_@@_path_lastx_dim
+ \dim_gset_eq:NN \g_@@_path_lasty_dim \l_@@_path_lasty_dim
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}
diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index e2332c4..fa947d2 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -285,13 +285,25 @@
% \begin{syntax}
% \cs{draw_scope_bb_begin:}
% ...
-% \cs{draw_scope_bb_begin:}
+% \cs{draw_scope_bb_end:}
% \end{syntax}
% Suspends (and saves) calculation of the bounding box of a drawing,
% resetting the tracking data and allowing the bounding box of the
% nested content to be calculated.
% \end{function}
%
+% \begin{function}{\draw_scope_path_begin:, \draw_scope_path_end:}
+% \begin{syntax}
+% \cs{draw_scope_path_begin:}
+% ...
+% \cs{draw_scope_path_end:}
+% \end{syntax}
+% Suspends (and saves) the current (partial) path, initialising a new
+% path within the scope. Path operations are written to output only when
+% used, so the scoped path is stored at the \pkg{expl3} level, not
+% in the output.
+% \end{function}
+%
% \subsection{Points}
%
% Functions supporting the calculation of points (co-ordinates) are expandable
diff --git a/l3experimental/l3draw/testfiles/m3draw000.tlg b/l3experimental/l3draw/testfiles/m3draw000.tlg
index ed216a3..1490456 100644
--- a/l3experimental/l3draw/testfiles/m3draw000.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw000.tlg
@@ -29,6 +29,14 @@ Author: Joseph Wright
\l__draw_xmin_dim=\dimen...
\l__draw_ymax_dim=\dimen...
\l__draw_ymin_dim=\dimen...
+\l__draw_path_lastx_dim=\dimen...
+\l__draw_path_lasty_dim=\dimen...
+\l__draw_path_xmax_dim=\dimen...
+\l__draw_path_xmin_dim=\dimen...
+\l__draw_path_ymax_dim=\dimen...
+\l__draw_path_ymin_dim=\dimen...
+\l__draw_softpath_lastx_dim=\dimen...
+\l__draw_softpath_lasty_dim=\dimen...
\g__draw_softpath_buffer_a_int=\count...
\g__draw_softpath_buffer_b_int=\count...
\g__draw_softpath_lastx_dim=\dimen...
More information about the latex3-commits
mailing list