summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx186
1 files changed, 150 insertions, 36 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx b/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx
index b87a6a152b7..451226ccdef 100644
--- a/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx
+++ b/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-scopes.dtx
@@ -42,7 +42,7 @@
% }^^A
% }
%
-% \date{Released 2018/02/21}
+% \date{Released 2018/03/05}
%
% \maketitle
%
@@ -72,11 +72,11 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}{\l_@@_update_bb_bool}
+% \begin{variable}{\l_draw_bb_update_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
+\bool_new:N \l_draw_bb_update_bool
% \end{macrocode}
% \end{variable}
%
@@ -87,47 +87,161 @@
% \end{macrocode}
% \end{variable}
%
+% \begin{variable}{\g_@@_id_int}
+% The drawing number.
+% \begin{macrocode}
+\int_new:N \g_@@_id_int
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\@@_reset_bb:}
+% A simple auxiliary.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_reset_bb:
+ {
+ \dim_gset:Nn \g_@@_xmax_dim { -\c_max_dim }
+ \dim_gset:Nn \g_@@_xmin_dim { \c_max_dim }
+ \dim_gset:Nn \g_@@_ymax_dim { -\c_max_dim }
+ \dim_gset:Nn \g_@@_ymin_dim { \c_max_dim }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \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 |\vbox| or like
-% a coffin). In contrast to \pkg{pgf}, we use a vertical box here: material
-% between explicit instructions should not be present anyway. (Consider
-% adding an |\everypar| hook as done for the \LaTeXe{} preamble.)
+% before inserting into the surroundings. Color is set here using the drawing
+% mechanism largely as it then sets up the internal data structures. It may be
+% that a coffin construct is better here in the longer term: that may become
+% clearer as the code is completed. As we need to avoid any insertion of
+% baseline skips, the outer box here has to be an |hbox|.
% \begin{macrocode}
\cs_new_protected:Npn \draw_begin:
{
- \vbox_set:Nw \l_@@_main_box
- \driver_draw_begin:
- \dim_gset:Nn \g_@@_xmax_dim { -\c_max_dim }
- \dim_gset:Nn \g_@@_xmin_dim { \c_max_dim }
- \dim_gset:Nn \g_@@_ymax_dim { -\c_max_dim }
- \dim_gset:Nn \g_@@_ymin_dim { \c_max_dim }
- \bool_set_true:N \l_@@_update_bb_bool
- \draw_transform_reset:
- \draw_linewidth:n { \l_draw_default_linewidth_dim }
+ \group_begin:
+ \int_gincr:N \g_@@_id_int
+ \hbox_set:Nw \l_@@_main_box
+ \driver_draw_begin:
+ \@@_reset_bb:
+ \@@_path_reset_limits:
+ \bool_set_true:N \l_draw_bb_update_bool
+ \draw_transform_matrix_reset:
+ \draw_transform_shift_reset:
+ \@@_softpath_clear:
+ \draw_linewidth:n { \l_draw_default_linewidth_dim }
+ \draw_color:n { . }
}
\cs_new_protected:Npn \draw_end:
{
- \driver_draw_end:
- \vbox_set_end:
- \hbox_set:Nn \l_@@_main_box
- {
- \skip_horizontal:n { -\g_@@_xmin_dim }
- \box_move_down:nn { \g_@@_ymin_dim }
- { \box_use_drop:N \l_@@_main_box }
- }
- \box_set_ht:Nn \l_@@_main_box
- { \g_@@_ymax_dim - \g_@@_ymin_dim }
- \box_set_dp:Nn \l_@@_main_box { 0pt }
- \box_set_wd:Nn \l_@@_main_box
- { \g_@@_xmax_dim - \g_@@_xmin_dim }
- \mode_leave_vertical:
- \box_use_drop:N \l_@@_main_box
+ \driver_draw_end:
+ \hbox_set_end:
+ \dim_compare:nNnT \g_@@_xmin_dim = \c_max_dim
+ {
+ \dim_gzero:N \g_@@_xmax_dim
+ \dim_gzero:N \g_@@_xmin_dim
+ \dim_gzero:N \g_@@_ymax_dim
+ \dim_gzero:N \g_@@_ymin_dim
+ }
+ \hbox_set:Nn \l_@@_main_box
+ {
+ \skip_horizontal:n { -\g_@@_xmin_dim }
+ \box_move_down:nn { \g_@@_ymin_dim }
+ { \box_use_drop:N \l_@@_main_box }
+ }
+ \box_set_ht:Nn \l_@@_main_box
+ { \g_@@_ymax_dim - \g_@@_ymin_dim }
+ \box_set_dp:Nn \l_@@_main_box { 0pt }
+ \box_set_wd:Nn \l_@@_main_box
+ { \g_@@_xmax_dim - \g_@@_xmin_dim }
+ \mode_leave_vertical:
+ \box_use_drop:N \l_@@_main_box
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Scopes}
+%
+% \begin{variable}{\l_@@_linewidth_dim}
+% \begin{variable}{\l_@@_fill_color_tl, \l_@@_stroke_color_tl}
+% Storage for local variables.
+% \begin{macrocode}
+\dim_new:N \l_@@_linewidth_dim
+\tl_new:N \l_@@_fill_color_tl
+\tl_new:N \l_@@_stroke_color_tl
+% \end{macrocode}
+% \end{variable}
+% \end{variable}
+%
+% \begin{macro}{\draw_scope_begin:, \draw_scope_begin:}
+% As well as the graphics (and \TeX{}) scope, also deal with global
+% data structures.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_scope_begin:
+ {
+ \driver_draw_scope_begin:
+ \group_begin:
+ \dim_set_eq:NN \l_@@_linewidth_dim \g_@@_linewidth_dim
+ \draw_path_scope_begin:
+ }
+\cs_new_protected:Npn \draw_scope_end:
+ {
+ \draw_path_scope_end:
+ \dim_gset_eq:NN \g_@@_linewidth_dim \l_@@_linewidth_dim
+ \group_end:
+ \driver_draw_scope_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{variable}
+% {\l_@@_xmax_dim, \l_@@_xmin_dim, \l_@@_ymax_dim, \l_@@_ymin_dim}
+% Storage for the bounding box.
+% \begin{macrocode}
+\dim_new:N \l_@@_xmax_dim
+\dim_new:N \l_@@_xmin_dim
+\dim_new:N \l_@@_ymax_dim
+\dim_new:N \l_@@_ymin_dim
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\@@_scope_bb_begin:, \@@_scope_bb_end:}
+% The bounding box is simple: a straight group-based save and restore
+% approach.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_scope_bb_begin:
+ {
+ \group_begin:
+ \dim_set_eq:NN \l_@@_xmax_dim \g_@@_xmax_dim
+ \dim_set_eq:NN \l_@@_xmin_dim \g_@@_xmin_dim
+ \dim_set_eq:NN \l_@@_ymax_dim \g_@@_ymax_dim
+ \dim_set_eq:NN \l_@@_ymin_dim \g_@@_ymin_dim
+ \@@_reset_bb:
+ }
+\cs_new_protected:Npn \@@_scope_bb_end:
+ {
+ \dim_gset_eq:NN \g_@@_xmax_dim \l_@@_xmax_dim
+ \dim_gset_eq:NN \g_@@_xmin_dim \l_@@_xmin_dim
+ \dim_gset_eq:NN \g_@@_ymax_dim \l_@@_ymax_dim
+ \dim_gset_eq:NN \g_@@_ymin_dim \l_@@_ymin_dim
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\draw_suspend_begin:, \draw_suspend_end:}
+% Suspend all parts of a drawing.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_suspend_begin:
+ {
+ \@@_scope_bb_begin:
+ \draw_path_scope_begin:
+ \draw_transform_matrix_reset:
+ \draw_transform_shift_reset:
+ }
+\cs_new_protected:Npn \draw_suspend_end:
+ {
+ \draw_path_scope_end:
+ \@@_scope_bb_end:
}
% \end{macrocode}
% \end{macro}