[latex3-commits] [git/LaTeX3-latex3-latex3] master: Initial drawing environment set up (a7c8a53)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Feb 6 23:31:55 CET 2018


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

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

commit a7c8a537c4e92eea990360dd0ca919e8728915d4
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Feb 6 21:42:34 2018 +0000

    Initial drawing environment set up
    
    Very basic at present: doesn't reset anything, doesn't check sizes, etc.
    
    I've deliberately left out the pgf setting of sizes to -16000pt: I'm not
    clear as-yet why these can't all simply be zero. Moreover, if they are
    meant to be 'out of the way' they should I feel be -\c_max_dim.


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

a7c8a537c4e92eea990360dd0ca919e8728915d4
 l3trial/l3draw/l3draw-paths.dtx        |   64 ++++++++++++++++++++++++++++++++
 l3trial/l3draw/l3draw-scopes.dtx       |   59 +++++++++++++++++++++++++++++
 l3trial/l3draw/l3draw.dtx              |    7 ++++
 l3trial/l3draw/testfiles/m3draw000.tlg |   11 ++++++
 4 files changed, 141 insertions(+)

diff --git a/l3trial/l3draw/l3draw-paths.dtx b/l3trial/l3draw/l3draw-paths.dtx
index c1f4143..a515f5a 100644
--- a/l3trial/l3draw/l3draw-paths.dtx
+++ b/l3trial/l3draw/l3draw-paths.dtx
@@ -60,6 +60,70 @@
 %<@@=draw>
 %    \end{macrocode}
 %
+% \subsection{Tracking paths}
+%
+% \begin{variable}{\g_@@_path_lastx_dim, \g_@@_path_lasty_dim}
+%   The last point visited on a path.
+%    \begin{macrocode}
+\dim_new:N \g_@@_path_lastx_dim
+\dim_new:N \g_@@_path_lasty_dim
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}
+%   {
+%     \g_@@_path_xmax_dim,
+%     \g_@@_path_xmin_dim,
+%     \g_@@_path_ymax_dim,
+%     \g_@@_path_ymin_dim
+%   }
+%   The limiting size of a path.
+%    \begin{macrocode}
+\dim_new:N \g_@@_path_xmax_dim
+\dim_new:N \g_@@_path_xmin_dim
+\dim_new:N \g_@@_path_ymax_dim
+\dim_new:N \g_@@_path_ymin_dim
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\@@_path_update_limits:nn}
+% \begin{macro}{\@@_path_reset_limits:}
+%   Track the limits of a path and (perhaps) of the picture as a whole.
+%   (At present the latter is always true: that will change as more complex
+%   functionality is added.)
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_path_update_limits:nn #1#2
+  {
+    \dim_gset:Nn \g_@@_path_xmax_dim
+      { \dim_max:nn \g_@@_path_xmax_dim {#1} }
+    \dim_gset:Nn \g_@@_path_xmin_dim
+      { \dim_min:nn \g_@@_path_xmax_dim {#1} }
+    \dim_gset:Nn \g_@@_path_ymax_dim
+      { \dim_max:nn \g_@@_path_ymax_dim {#1} }
+    \dim_gset:Nn \g_@@_path_ymin_dim
+      { \dim_min:nn \g_@@_path_ymin_dim {#1} }
+    \bool_if:NT \l_@@_update_bb_bool
+      {
+        \dim_gset:Nn \g_@@_xmax_dim
+          { \dim_max:nn \g_@@_xmax_dim {#1} }
+        \dim_gset:Nn \g_@@_xmin_dim
+          { \dim_min:nn \g_@@_xmax_dim {#1} }
+        \dim_gset:Nn \g_@@_ymax_dim
+          { \dim_max:nn \g_@@_ymax_dim {#1} }
+        \dim_gset:Nn \g_@@_ymin_dim
+          { \dim_min:nn \g_@@_ymin_dim {#1} }
+      }
+  }
+\cs_new_protected:Npn \@@_path_reset_limits:
+  {
+    \dim_zero:N \g_@@_path_xmax_dim
+    \dim_zero:N \g_@@_path_xmin_dim
+    \dim_zero:N \g_@@_path_ymax_dim
+    \dim_zero:N \g_@@_path_ymin_dim
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3trial/l3draw/l3draw-scopes.dtx b/l3trial/l3draw/l3draw-scopes.dtx
index fd13fc4..2f425b4 100644
--- a/l3trial/l3draw/l3draw-scopes.dtx
+++ b/l3trial/l3draw/l3draw-scopes.dtx
@@ -60,6 +60,65 @@
 %<@@=draw>
 %    \end{macrocode}
 %
+% \subsection{Drawing environment}
+%
+% \begin{variable}
+%   {\g_@@_xmax_dim, \g_@@_xmin_dim, \g_@@_ymax_dim, \g_@@_ymin_dim}
+%   Used to track the overall (official) size of the image created: may
+%   not actually be the natural size of the content.
+%    \begin{macrocode}
+\dim_new:N \g_@@_xmax_dim
+\dim_new:N \g_@@_xmin_dim
+\dim_new:N \g_@@_ymax_dim
+\dim_new:N \g_@@_ymin_dim
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\l_@@_update_bb_bool}
+%   Flag to indicate that a path (or similar) should update the bounding box
+%   of the drawing.
+%    \begin{macrocode}
+\bool_new:N \l_@@_update_bb_bool
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\l_@@_main_box}
+%   Box for setting the drawing.
+%    \begin{macrocode}
+\box_new:N \l_@@_main_box
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\draw_begin:, \draw_end:}
+%   Drawings are created by setting them into a box, then adjusting the box
+%   before inserting into the surroundings. At present the content is simply
+%   collected then dumped: work will be required to manipulate the size as
+%   this data becomes more defined. It may be that a coffin construct is
+%   better here in the longer term: that may become clearer as the code is
+%   completed. Another obvious question is whether/where vertical mode should
+%   be ended (\emph{i.e.}~should this behave like a raw |\hbox| or like
+%   a coffin).
+%    \begin{macrocode}
+\cs_new_protected:Npn \draw_begin:
+  {
+    \hbox_set:Nw \l_@@_main_box
+      \driver_draw_begin:
+      \dim_gzero:N \g_@@_xmax_dim
+      \dim_gzero:N \g_@@_xmin_dim
+      \dim_gzero:N \g_@@_ymax_dim
+      \dim_gzero:N \g_@@_ymin_dim
+      \bool_set_true:N \l_@@_update_bb_bool
+  }
+\cs_new_protected:Npn \draw_end:
+  {
+      \driver_draw_end:
+    \hbox_set_end:
+    \mode_leave_vertical:
+    \box_use_drop:N \l_@@_main_box
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index 09866a8..2ddb42f 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -52,6 +52,13 @@
 %
 % \section{\pkg{l3draw} documentation}
 %
+% \begin{function}{\draw_begin:, \draw_end:}
+%   \begin{syntax}
+%     \cs{draw_begin:}
+%     ...
+%     \cs{draw_end:}
+%   \end{syntax}
+%
 % \end{documentation}
 %
 % \begin{implementation}
diff --git a/l3trial/l3draw/testfiles/m3draw000.tlg b/l3trial/l3draw/testfiles/m3draw000.tlg
index 8b21f53..a17ff47 100644
--- a/l3trial/l3draw/testfiles/m3draw000.tlg
+++ b/l3trial/l3draw/testfiles/m3draw000.tlg
@@ -2,4 +2,15 @@ This is a generated file for the LaTeX (2e + expl3) validation system.
 Don't change this file in any respect.
 Author: Joseph Wright
 (l3draw.sty
+\g__draw_path_lastx_dim=\dimen...
+\g__draw_path_lasty_dim=\dimen...
+\g__draw_path_xmax_dim=\dimen...
+\g__draw_path_xmin_dim=\dimen...
+\g__draw_path_ymax_dim=\dimen...
+\g__draw_path_ymin_dim=\dimen...
+\g__draw_xmax_dim=\dimen...
+\g__draw_xmin_dim=\dimen...
+\g__draw_ymax_dim=\dimen...
+\g__draw_ymin_dim=\dimen...
+\l__draw_main_box=\box...
 )





More information about the latex3-commits mailing list