summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx182
1 files changed, 159 insertions, 23 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx b/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx
index 2fa882e7f1a..09df8391d17 100644
--- a/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx
+++ b/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-paths.dtx
@@ -42,7 +42,7 @@
% }^^A
% }
%
-% \date{Released 2018/02/21}
+% \date{Released 2018/03/05}
%
% \maketitle
%
@@ -128,7 +128,7 @@
{ \dim_max:nn \g_@@_path_ymax_dim {#2} }
\dim_gset:Nn \g_@@_path_ymin_dim
{ \dim_min:nn \g_@@_path_ymin_dim {#2} }
- \bool_if:NT \l_@@_update_bb_bool
+ \bool_if:NT \l_draw_bb_update_bool
{
\dim_gset:Nn \g_@@_xmax_dim
{ \dim_max:nn \g_@@_xmax_dim {#1} }
@@ -185,15 +185,10 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}{\draw_path_corner_arc:n}
-% \begin{macro}{\@@_path_corner_arc:nn}
+% \begin{macro}{\draw_path_corner_arc:nn}
% Calculate the arcs, check they are non-zero.
% \begin{macrocode}
-\cs_new_protected:Npn \draw_path_corner_arc:n #1
- {
- \@@_point_process:nn { \@@_path_corner_arc:nn } {#1}
- }
-\cs_new_protected:Npn \@@_path_corner_arc:nn #1#2
+\cs_new_protected:Npn \draw_path_corner_arc:nn #1#2
{
\dim_set:Nn \l_@@_corner_xarc_dim {#1}
\dim_set:Nn \l_@@_corner_yarc_dim {#2}
@@ -205,7 +200,6 @@
}
% \end{macrocode}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\@@_path_mark_corner:}
% Mark up corners for arc post-processing.
@@ -295,6 +289,33 @@
% \end{macrocode}
% \end{macro}
%
+% \subsection{Canvas path constructions}
+%
+% \begin{macro}{\draw_path_canvas_moveto:n, \draw_path_canvas_lineto:n}
+% \begin{macro}{\draw_path_canvas_curveto:nnn}
+% Operations with no application of the transformation matrix.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_path_canvas_moveto:n #1
+ { \@@_point_process:nn { \@@_path_moveto:nn } {#1} }
+\cs_new_protected:Npn \draw_path_canvas_lineto:n #1
+ { \@@_point_process:nn { \@@_path_lineto:nn } {#1} }
+\cs_new_protected:Npn \draw_path_canvas_curveto:nnn #1#2#3
+ {
+ \@@_point_process:nnn
+ {
+ \@@_point_process:nn
+ {
+ \@@_path_mark_corner:
+ \@@_path_curveto:nnnnnn
+ }
+ {#1}
+ }
+ {#2} {#3}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Computed curves}
%
% More complex operations need some calculations. To assist with those, various
@@ -690,7 +711,9 @@
{
\@@_point_process:nnn
{
- \bool_if:NTF \l_@@_corner_arc_bool
+ \bool_lazy_or:nnTF
+ { \l_@@_corner_arc_bool }
+ { \l_@@_matrix_active_bool }
{ \@@_path_rectangle_rounded:nnnn }
{ \@@_path_rectangle:nnnn }
}
@@ -736,33 +759,71 @@
% \subsection{Grids}
%
% \begin{macro}{\draw_path_grid:nnnn}
-% \begin{macro}{\@@_path_grid:nnnnnn}
-% A simple set of loops.
+% \begin{macro}
+% {
+% \@@_path_grid_auxi:nnnnnn, \@@_path_grid_auxi:ffnnnn,
+% \@@_path_grid_auxii:nnnnnn,
+% \@@_path_grid_auxiii:nnnnnn, \@@_path_grid_auxiiii:ffnnnn
+% }
+% \begin{macro}
+% {\@@_path_grid_auxiv:nnnnnnnn, \@@_path_grid_auxiv:ffnnnnnn}
+% The main complexity here is lining up the grid correctly.
+% To keep it simple, we tidy up the argument ordering first.
% \begin{macrocode}
\cs_new_protected:Npn \draw_path_grid:nnnn #1#2#3#4
{
\@@_point_process:nnn
- { \@@_path_grid:nnnnnn {#1} {#2} }
+ {
+ \@@_path_grid_auxi:ffnnnn
+ { \dim_eval:n { \dim_abs:n {#1} } }
+ { \dim_eval:n { \dim_abs:n {#2} } }
+ }
{#3} {#4}
}
-\cs_new_protected:Npn \@@_path_grid:nnnnnn #1#2#3#4#5#6
+\cs_new_protected:Npn \@@_path_grid_auxi:nnnnnn #1#2#3#4#5#6
+ {
+ \dim_compare:nNnTF {#3} > {#5}
+ { \@@_path_grid_auxii:nnnnnn {#1} {#2} {#5} {#4} {#3} {#6} }
+ { \@@_path_grid_auxii:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} }
+ }
+\cs_generate_variant:Nn \@@_path_grid_auxi:nnnnnn { ff }
+\cs_new_protected:Npn \@@_path_grid_auxii:nnnnnn #1#2#3#4#5#6
+ {
+ \dim_compare:nNnTF {#4} > {#6}
+ { \@@_path_grid_auxiii:nnnnnn {#1} {#2} {#3} {#6} {#5} {#4} }
+ { \@@_path_grid_auxiii:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} }
+ }
+\cs_new_protected:Npn \@@_path_grid_auxiii:nnnnnn #1#2#3#4#5#6
+ {
+ \@@_path_grid_auxiv:ffnnnnnn
+ { \fp_to_dim:n { #1 * trunc(#3/(#1)) } }
+ { \fp_to_dim:n { #2 * trunc(#4/(#2)) } }
+ {#1} {#2} {#3} {#4} {#5} {#6}
+ }
+\cs_new_protected:Npn \@@_path_grid_auxiv:nnnnnnnn #1#2#3#4#5#6#7#8
{
\dim_step_inline:nnnn
- {#3} { \dim_compare:nNnF {#3} < {#5} { - } \dim_abs:n {#1} } {#5}
+ {#1}
+ {#3}
+ {#7}
{
- \draw_path_moveto:n { ##1 , #4 }
- \draw_path_lineto:n { ##1 , #6 }
+ \draw_path_moveto:n { ##1 , #6 }
+ \draw_path_lineto:n { ##1 , #8 }
}
\dim_step_inline:nnnn
- {#4} { \dim_compare:nNnF {#4} < {#6} { - } \dim_abs:n {#2} } {#6}
+ {#2}
+ {#4}
+ {#8}
{
- \draw_path_moveto:n { #3 , ##1 }
- \draw_path_lineto:n { #5 , ##1 }
+ \draw_path_moveto:n { #5 , ##1 }
+ \draw_path_lineto:n { #7 , ##1 }
}
}
+\cs_generate_variant:Nn \@@_path_grid_auxiv:nnnnnnnn { ff }
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Using paths}
%
@@ -790,7 +851,7 @@
%
% \begin{macro}{\draw_path_use:n, \draw_path_use_clear:n}
% \begin{macro}{\@@_path_use:n}
-% \begin{macro}{\@@_path_use_action_draw:}
+% \begin{macro}{\@@_path_use_action_draw:, \@@_path_use_action_fillstroke:}
% \begin{macro}{\@@_path_use_stroke_bb:}
% \begin{macro}{\@@_path_use_stroke_bb_aux:NnN}
% There are a range of actions which can apply to a path: they are handled
@@ -833,8 +894,9 @@
{ \ERROR }
}
}
+ \@@_softpath_round_corners:
\bool_lazy_and:nnT
- { \l_@@_update_bb_bool }
+ { \l_draw_bb_update_bool }
{ \l_@@_path_use_stroke_bool }
{ \@@_path_use_stroke_bb: }
\bool_if:NTF \l_@@_path_use_clear_bool
@@ -859,6 +921,11 @@
{
\bool_set_true:N \l_@@_path_use_stroke_bool
}
+\cs_new_protected:Npn \@@_path_use_action_fillstroke:
+ {
+ \bool_set_true:N \l_@@_path_use_fill_bool
+ \bool_set_true:N \l_@@_path_use_stroke_bool
+ }
% \end{macrocode}
% Where the path is relevant to size and is stroked, we need to allow for
% the part which overlaps the edge of the bounding box.
@@ -892,6 +959,75 @@
% \end{macro}
% \end{macro}
%
+% \subsection{Scoping paths}
+%
+% \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_path_scope_begin:, \draw_path_scope_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_path_scope_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_path_scope_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}