[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add dash patterns to drawings (c7a957f)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Mar 8 22:47:46 CET 2018


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

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

commit c7a957f8a01dcbf3044f8b574145bc1085c7fbaa
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Mar 8 21:47:46 2018 +0000

    Add dash patterns to drawings
    
    This rounds out l3draw-scope, at least until inner
    lines are sorted out.


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

c7a957f8a01dcbf3044f8b574145bc1085c7fbaa
 l3experimental/l3draw/l3draw-state.dtx             |   36 ++++++++++
 l3experimental/l3draw/l3draw.dtx                   |   38 +++++++++++
 l3experimental/l3draw/testfiles/m3draw004.lvt      |    6 ++
 l3experimental/l3draw/testfiles/m3draw004.ptex.tlg |   70 ++++++++++++++++++--
 l3experimental/l3draw/testfiles/m3draw004.tlg      |   70 ++++++++++++++++++--
 .../l3draw/testfiles/m3draw004.uptex.tlg           |   70 ++++++++++++++++++--
 .../l3draw/testfiles/m3draw004.xetex.tlg           |   70 ++++++++++++++++++--
 7 files changed, 336 insertions(+), 24 deletions(-)

diff --git a/l3experimental/l3draw/l3draw-state.dtx b/l3experimental/l3draw/l3draw-state.dtx
index 6c1438e..8d7f4d7 100644
--- a/l3experimental/l3draw/l3draw-state.dtx
+++ b/l3experimental/l3draw/l3draw-state.dtx
@@ -58,6 +58,15 @@
 %<@@=draw>
 %    \end{macrocode}
 %
+% This sub-module covers more-or-less the same ideas as
+% \texttt{pgfcoregraphicstate.code.tex}. At present, equivalents of the
+% following are currently absent:
+% \begin{itemize}
+%   \item \cs{pgfsetinnerlinewidth}, \cs{pgfinnerlinewidth},
+%     \cs{pgfsetinnerstrokecolor}, \cs{pgfsetinnerstrokecolor}: Likely to
+%     be added on further work is done on paths/stroking.
+% \end{itemize}
+%
 % \begin{variable}{\g_@@_linewidth_dim}
 %   Linewidth for strokes: global as the scope for this relies on the graphics
 %   state. The inner line width is used for places where two lines are used.
@@ -86,6 +95,33 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\draw_dash_pattern:nn}
+% \begin{variable}{\l_@@_tmp_clist}
+%   Evaluated all of the list and pass it to the driver layer.
+%    \begin{macrocode}
+\cs_new_protected:Npn \draw_dash_pattern:nn #1#2
+  {
+    \group_begin:
+      \clist_clear:N \l_@@_tmp_clist
+      \clist_map_inline:nn {#1}
+        {
+          \clist_put_right:Nx \l_@@_tmp_clist
+            { \fp_to_dim:n {##1} }
+        }
+      \clist_set:Nn \l_@@_tmp_clist {#1}
+      \use:x
+        {
+          \driver_draw_dash_pattern:nn
+            { \clist_use:Nnnn \l_@@_tmp_clist { , } { , } { , } }
+            { \fp_to_dim:n {#2} }
+        }
+    \group_end:
+  }
+\clist_new:N \l_@@_tmp_clist
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{\draw_miterlimit:n}
 %   Pass through to the driver layer.
 %    \begin{macrocode}
diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index 12a3fb9..fa6c879 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -226,6 +226,44 @@
 %   \meta{fp expr}).
 % \end{function}
 %
+% \begin{function}{\draw_dash_pattern:nn}
+%   \begin{syntax}
+%     \cs{draw_dash_pattern:nn} \Arg{pattern} \Arg{phase}
+%   \end{syntax}
+%   Specifies a dash pattern. The \meta{pattern} itself is a comma-separated
+%   list of entries which represent the \enquote{on} and \enquote{off}
+%   parts of the line. These are all \meta{fp expr} and repeat as required.
+%   Thus the \meta{pattern} may be of arbitrary length. The \meta{phase}
+%   specifies where during the first \enquote{on} line the pattern should
+%   start.
+%   \begin{demo}
+%     \draw_begin:
+%       \draw_dash_pattern:nn
+%         { 0.5cm , 0.5cm , 0.1cm , 0.2cm }
+%         { 0cm }
+%       \draw_path_moveto:n { 0cm , 0cm }
+%       \draw_path_lineto:n { 2cm , 0cm }
+%       \draw_path_use_clear:n { stroke }
+%       \draw_dash_pattern:nn
+%         { 0.5cm , 0.5cm , 0.1cm , 0.2cm }
+%         { 0.1cm }
+%       \draw_path_moveto:n { 0cm , 1mm }
+%       \draw_path_lineto:n { 2cm , 1mm }
+%       \draw_path_use_clear:n { stroke }
+%       \draw_dash_pattern:nn
+%         { 0.5cm , 0.5cm , 0.1cm , 0.2cm }
+%         { 0.2cm }
+%       \draw_path_moveto:n { 0cm , 2mm }
+%       \draw_path_lineto:n { 2cm , 2mm }
+%       \draw_path_use_clear:n { stroke }
+%     \draw_end:
+%   \end{demo}
+%   Setting an empty pattern will produce a solid line.
+%   
+%   Note the \meta{pattern} interface here is different from that in \pkg{pgf}:
+%   the list is comma-separated not given in brace groups.
+% \end{function}
+%
 % \begin{function}{\draw_nonzero_rule:, \draw_evenodd_rule:}
 %   \begin{syntax}
 %     \cs{draw_nonzero_rule:}
diff --git a/l3experimental/l3draw/testfiles/m3draw004.lvt b/l3experimental/l3draw/testfiles/m3draw004.lvt
index 9d1bb5e..932213e 100644
--- a/l3experimental/l3draw/testfiles/m3draw004.lvt
+++ b/l3experimental/l3draw/testfiles/m3draw004.lvt
@@ -44,6 +44,12 @@
     \test:n { \draw_linewidth:n { 1pt } }
   }
 
+\TEST { \draw_dash_pattern:nn }
+  {
+    \test:n { \draw_dash_pattern:nn { } { 0 } }
+    \test:n { \draw_dash_pattern:nn { 0.2cm , 0.2cm } { 0 } }
+    \test:n { \draw_dash_pattern:nn { 0.2cm , 0.2cm } { 0.1cm } }
+  }
 
 \TEST { \draw_cap_... }
   {
diff --git a/l3experimental/l3draw/testfiles/m3draw004.ptex.tlg b/l3experimental/l3draw/testfiles/m3draw004.ptex.tlg
index d66363a..5b4e9f4 100644
--- a/l3experimental/l3draw/testfiles/m3draw004.ptex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw004.ptex.tlg
@@ -61,7 +61,65 @@ TEST 2: \draw_linewidth:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: \draw_cap_ ...
+TEST 3: \draw_dash_pattern:nn 
+============================================================
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [] 0 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [5.6692 5.6692] 0 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [5.6692 5.6692] 2.83464 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
+============================================================
+TEST 4: \draw_cap_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -119,7 +177,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: \draw_join_ ...
+TEST 5: \draw_join_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -177,7 +235,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: \draw_miterlimit:n 
+TEST 6: \draw_miterlimit:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -235,7 +293,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: \draw_color:n 
+TEST 7: \draw_color:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -285,7 +343,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: \draw_color_fill:n 
+TEST 8: \draw_color_fill:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -313,7 +371,7 @@ TEST 7: \draw_color_fill:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: \draw_color_stroke:n 
+TEST 9: \draw_color_stroke:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
diff --git a/l3experimental/l3draw/testfiles/m3draw004.tlg b/l3experimental/l3draw/testfiles/m3draw004.tlg
index 7250697..90efd75 100644
--- a/l3experimental/l3draw/testfiles/m3draw004.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw004.tlg
@@ -61,7 +61,65 @@ TEST 2: \draw_linewidth:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: \draw_cap_ ...
+TEST 3: \draw_dash_pattern:nn 
+============================================================
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\pdfsave
+...\pdfliteral{0.3985 w}
+...\pdfcolorstack 0 push {0 g 0 G}
+...\pdfliteral{[] 0 d}
+...\pdfliteral{0 0 m}
+...\pdfliteral{28.34647 283.46457 l}
+...\pdfliteral{56.69292 0 l}
+...\pdfliteral{S}
+...\pdfrestore
+...\pdfcolorstack 0 pop
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\pdfsave
+...\pdfliteral{0.3985 w}
+...\pdfcolorstack 0 push {0 g 0 G}
+...\pdfliteral{[5.6692 5.6692] 0 d}
+...\pdfliteral{0 0 m}
+...\pdfliteral{28.34647 283.46457 l}
+...\pdfliteral{56.69292 0 l}
+...\pdfliteral{S}
+...\pdfrestore
+...\pdfcolorstack 0 pop
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\pdfsave
+...\pdfliteral{0.3985 w}
+...\pdfcolorstack 0 push {0 g 0 G}
+...\pdfliteral{[5.6692 5.6692] 2.83464 d}
+...\pdfliteral{0 0 m}
+...\pdfliteral{28.34647 283.46457 l}
+...\pdfliteral{56.69292 0 l}
+...\pdfliteral{S}
+...\pdfrestore
+...\pdfcolorstack 0 pop
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
+============================================================
+TEST 4: \draw_cap_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -119,7 +177,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: \draw_join_ ...
+TEST 5: \draw_join_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -177,7 +235,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: \draw_miterlimit:n 
+TEST 6: \draw_miterlimit:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -235,7 +293,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: \draw_color:n 
+TEST 7: \draw_color:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -285,7 +343,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: \draw_color_fill:n 
+TEST 8: \draw_color_fill:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -316,7 +374,7 @@ TEST 7: \draw_color_fill:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: \draw_color_stroke:n 
+TEST 9: \draw_color_stroke:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
diff --git a/l3experimental/l3draw/testfiles/m3draw004.uptex.tlg b/l3experimental/l3draw/testfiles/m3draw004.uptex.tlg
index d66363a..5b4e9f4 100644
--- a/l3experimental/l3draw/testfiles/m3draw004.uptex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw004.uptex.tlg
@@ -61,7 +61,65 @@ TEST 2: \draw_linewidth:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: \draw_cap_ ...
+TEST 3: \draw_dash_pattern:nn 
+============================================================
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [] 0 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [5.6692 5.6692] 0 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [5.6692 5.6692] 2.83464 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
+============================================================
+TEST 4: \draw_cap_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -119,7 +177,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: \draw_join_ ...
+TEST 5: \draw_join_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -177,7 +235,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: \draw_miterlimit:n 
+TEST 6: \draw_miterlimit:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -235,7 +293,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: \draw_color:n 
+TEST 7: \draw_color:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -285,7 +343,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: \draw_color_fill:n 
+TEST 8: \draw_color_fill:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -313,7 +371,7 @@ TEST 7: \draw_color_fill:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: \draw_color_stroke:n 
+TEST 9: \draw_color_stroke:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
diff --git a/l3experimental/l3draw/testfiles/m3draw004.xetex.tlg b/l3experimental/l3draw/testfiles/m3draw004.xetex.tlg
index d66363a..5b4e9f4 100644
--- a/l3experimental/l3draw/testfiles/m3draw004.xetex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw004.xetex.tlg
@@ -61,7 +61,65 @@ TEST 2: \draw_linewidth:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 3: \draw_cap_ ...
+TEST 3: \draw_dash_pattern:nn 
+============================================================
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [] 0 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [5.6692 5.6692] 0 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+> \box...=
+\hbox(284.92755+0.0)x57.30551
+.\hbox(284.92755+0.0)x57.30551
+..\glue 0.2
+..\hbox(0.0+0.0)x0.0, shifted -0.2
+...\special{x:gsave}
+...\special{pdf:literal 0.3985 w}
+...\special{color push gray 0}
+...\special{pdf:literal [5.6692 5.6692] 2.83464 d}
+...\special{pdf:literal 0 0 m}
+...\special{pdf:literal 28.34647 283.46457 l}
+...\special{pdf:literal 56.69292 0 l}
+...\special{pdf:literal S}
+...\special{x:grestore}
+...\special{color pop}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
+============================================================
+TEST 4: \draw_cap_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -119,7 +177,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: \draw_join_ ...
+TEST 5: \draw_join_ ...
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -177,7 +235,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 5: \draw_miterlimit:n 
+TEST 6: \draw_miterlimit:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -235,7 +293,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 6: \draw_color:n 
+TEST 7: \draw_color:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -285,7 +343,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 7: \draw_color_fill:n 
+TEST 8: \draw_color_fill:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551
@@ -313,7 +371,7 @@ TEST 7: \draw_color_fill:n
 l. ...  }
 ============================================================
 ============================================================
-TEST 8: \draw_color_stroke:n 
+TEST 9: \draw_color_stroke:n 
 ============================================================
 > \box...=
 \hbox(284.92755+0.0)x57.30551





More information about the latex3-commits mailing list