[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add canvas path ops to l3draw (4d6482d)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Feb 22 08:17:25 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/4d6482d63c7a66a6aa4bf509d9c73272bb344d57
>---------------------------------------------------------------
commit 4d6482d63c7a66a6aa4bf509d9c73272bb344d57
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Feb 22 07:17:25 2018 +0000
Add canvas path ops to l3draw
Useful for Hobby paths, and in pgf done by
simply setting \pgf at x/\pgf at y directly ...
>---------------------------------------------------------------
4d6482d63c7a66a6aa4bf509d9c73272bb344d57
l3experimental/l3draw/l3draw-paths.dtx | 28 +++++++
l3experimental/l3draw/l3draw.dtx | 77 ++++++++++++++++----
l3experimental/l3draw/testfiles/m3draw003.lvt | 36 +++++++++
l3experimental/l3draw/testfiles/m3draw003.ptex.tlg | 54 ++++++++++++++
l3experimental/l3draw/testfiles/m3draw003.tlg | 54 ++++++++++++++
.../l3draw/testfiles/m3draw003.uptex.tlg | 54 ++++++++++++++
.../l3draw/testfiles/m3draw003.xetex.tlg | 54 ++++++++++++++
7 files changed, 341 insertions(+), 16 deletions(-)
diff --git a/l3experimental/l3draw/l3draw-paths.dtx b/l3experimental/l3draw/l3draw-paths.dtx
index 2fa882e..ebd0c16 100644
--- a/l3experimental/l3draw/l3draw-paths.dtx
+++ b/l3experimental/l3draw/l3draw-paths.dtx
@@ -295,6 +295,34 @@
% \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
diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index 35010d3..fbfcdd7 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -84,6 +84,15 @@
% switch out of vertical mode if required.
% \end{function}
%
+% Within a drawing, there are different ways of referring to a position.
+% The co-ordinates of a point are given relative to the current
+% \emph{drawing axes}. These can be manipulated and tracked at the code
+% level. Underlying this is the \meta{canvas}, which is at the \pkg{draw}
+% level essentially fixed and in line with the paper. Initially, the two
+% sets of axes are coincident. (It is possible to manipulate the canvas
+% axes at the driver level: this is then \enquote{transparent} to the
+% \pkg{draw} level, and so should be used only when strictly required.)
+%
% \subsection{Graphics state}
%
% Within the drawing environment, a number of functions control how drawings
@@ -368,6 +377,36 @@
% corner arcs are not activated in the code.}
% \end{function}
%
+% \begin{function}{\draw_path_close:}
+% \begin{syntax}
+% \cs{draw_path_close:}
+% \end{syntax}
+% Closes the current part of the path by appending a straight line from
+% the current point to the starting point of the path.
+% \end{function}
+%
+% \begin{function}{\draw_path_use:n, \draw_path_use_clear:n}
+% \begin{syntax}
+% \cs{draw_path_use:n} \Arg{action(s)}
+% \end{syntax}
+% Inserts the current path, carrying out one ore more possible \meta{actions}
+% (a comma list):
+% \begin{itemize}
+% \item \texttt{clear} Resets the path to empty
+% \item \texttt{clip} Clips any content outside of the path
+% \item \texttt{draw}
+% \item \texttt{fill} Fills the interior of the path with the current
+% file color
+% \item \texttt{stroke} Draws a line along the current path
+% \end{itemize}
+% \end{function}
+%
+% \subsubsection{Path operations on drawing axes}
+%
+% The standard path functions are all influenced by the active transformation
+% matrix, \emph{i.e.}~the work relative to the drawing axes rather than
+% the canvas.
+%
% \begin{function}{\draw_path_moveto:n}
% \begin{syntax}
% \cs{draw_path_moveto:n} \Arg{point}
@@ -454,28 +493,34 @@
% current path.
% \end{function}
%
-% \begin{function}{\draw_path_close:}
+% \subsubsection{Path operations on canvas axes}
+%
+% For \emph{specialist} work, a small number of functions are provided
+% which work relative to the canvas axes, \emph{i.e.}~these functions
+% ignore the transformation matrix.
+%
+% \begin{function}{\draw_path_canvas_moveto:n}
% \begin{syntax}
-% \cs{draw_path_close:}
+% \cs{draw_path_canvas_moveto:n} \Arg{canvas point}
% \end{syntax}
-% Closes the current part of the path by appending a straight line from
-% the current point to the starting point of the path.
+% Moves the reference point of the path to the \meta{canvas point}, but will
+% not join this to any previous point.
% \end{function}
%
-% \begin{function}{\draw_path_use:n, \draw_path_use_clear:n}
+% \begin{function}{\draw_path_canvas_lineto:n}
% \begin{syntax}
-% \cs{draw_path_use:n} \Arg{action(s)}
+% \cs{draw_path_canvas_lineto:n} \Arg{canvas point}
% \end{syntax}
-% Inserts the current path, carrying out one ore more possible \meta{actions}
-% (a comma list):
-% \begin{itemize}
-% \item \texttt{clear} Resets the path to empty
-% \item \texttt{clip} Clips any content outside of the path
-% \item \texttt{draw}
-% \item \texttt{fill} Fills the interior of the path with the current
-% file color
-% \item \texttt{stroke} Draws a line along the current path
-% \end{itemize}
+% Joins the current path to the \meta{canvas point} with a straight line.
+% \end{function}
+%
+% \begin{function}{\draw_path_canvas_curveto:nnn}
+% \begin{syntax}
+% \cs{draw_path_canvas_curveto:nnn} \Arg{control1} \Arg{control2} \Arg{end}
+% \end{syntax}
+% Joins the current path to the \meta{end} with a curved line defined by
+% cubic Bézier points \meta{control1} and \meta{control2}. These positions
+% are given as canvas points.
% \end{function}
%
% \subsection{Color}
diff --git a/l3experimental/l3draw/testfiles/m3draw003.lvt b/l3experimental/l3draw/testfiles/m3draw003.lvt
index 791d20a..fdfcaec 100644
--- a/l3experimental/l3draw/testfiles/m3draw003.lvt
+++ b/l3experimental/l3draw/testfiles/m3draw003.lvt
@@ -212,4 +212,40 @@
}
}
+\TEST { \draw_path_canvas_moveto:n }
+ {
+ \test:n
+ {
+ \draw_path_canvas_moveto:n { 10pt , 10pt }
+ \draw_transform:nnnnn { 2 } { 1 } { 0 } { 1 } { 10 , 10 }
+ \draw_path_canvas_moveto:n { 10pt , 10pt }
+ }
+ }
+
+\TEST { \draw_path_canvas_lineto:n }
+ {
+ \test:n
+ {
+ \draw_path_canvas_lineto:n { 10pt , 10pt }
+ \draw_transform:nnnnn { 2 } { 1 } { 0 } { 1 } { 10 , 10 }
+ \draw_path_canvas_lineto:n { 10pt , 10pt }
+ }
+ }
+
+\TEST { \draw_path_canvas_curveto:nnn }
+ {
+ \test:n
+ {
+ \draw_path_canvas_curveto:nnn
+ { \draw_point_vec:nn { 0 } { 1 } }
+ { \draw_point_vec:nn { 1 } { 1 } }
+ { \draw_point_vec:nn { 1 } { 2 } }
+ \draw_transform:nnnnn { 2 } { 1 } { 0 } { 1 } { 10 , 10 }
+ \draw_path_canvas_curveto:nnn
+ { \draw_point_vec:nn { 0 } { 1 } }
+ { \draw_point_vec:nn { 1 } { 1 } }
+ { \draw_point_vec:nn { 1 } { 2 } }
+ }
+ }
+
\END
diff --git a/l3experimental/l3draw/testfiles/m3draw003.ptex.tlg b/l3experimental/l3draw/testfiles/m3draw003.ptex.tlg
index 6f68600..b88423c 100644
--- a/l3experimental/l3draw/testfiles/m3draw003.ptex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw003.ptex.tlg
@@ -503,3 +503,57 @@ l. ... }
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 12: \draw_path_canvas_moveto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 9.96265 9.96265 m}
+...\special{pdf:literal 9.96265 9.96265 m}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 13: \draw_path_canvas_lineto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 9.96265 9.96265 l}
+...\special{pdf:literal 9.96265 9.96265 l}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 14: \draw_path_canvas_curveto:nnn
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\special{pdf:literal 0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw003.tlg b/l3experimental/l3draw/testfiles/m3draw003.tlg
index 3d6dad4..6caa95d 100644
--- a/l3experimental/l3draw/testfiles/m3draw003.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw003.tlg
@@ -503,3 +503,57 @@ l. ... }
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 12: \draw_path_canvas_moveto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{9.96265 9.96265 m}
+...\pdfliteral{9.96265 9.96265 m}
+...\pdfliteral{S}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 13: \draw_path_canvas_lineto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{9.96265 9.96265 l}
+...\pdfliteral{9.96265 9.96265 l}
+...\pdfliteral{S}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 14: \draw_path_canvas_curveto:nnn
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\pdfliteral{0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\pdfliteral{S}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw003.uptex.tlg b/l3experimental/l3draw/testfiles/m3draw003.uptex.tlg
index 6f68600..b88423c 100644
--- a/l3experimental/l3draw/testfiles/m3draw003.uptex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw003.uptex.tlg
@@ -503,3 +503,57 @@ l. ... }
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 12: \draw_path_canvas_moveto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 9.96265 9.96265 m}
+...\special{pdf:literal 9.96265 9.96265 m}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 13: \draw_path_canvas_lineto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 9.96265 9.96265 l}
+...\special{pdf:literal 9.96265 9.96265 l}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 14: \draw_path_canvas_curveto:nnn
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\special{pdf:literal 0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
diff --git a/l3experimental/l3draw/testfiles/m3draw003.xetex.tlg b/l3experimental/l3draw/testfiles/m3draw003.xetex.tlg
index 6f68600..b88423c 100644
--- a/l3experimental/l3draw/testfiles/m3draw003.xetex.tlg
+++ b/l3experimental/l3draw/testfiles/m3draw003.xetex.tlg
@@ -503,3 +503,57 @@ l. ... }
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 12: \draw_path_canvas_moveto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 9.96265 9.96265 m}
+...\special{pdf:literal 9.96265 9.96265 m}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 13: \draw_path_canvas_lineto:n
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 9.96265 9.96265 l}
+...\special{pdf:literal 9.96265 9.96265 l}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 14: \draw_path_canvas_curveto:nnn
+============================================================
+> \box...=
+\hbox(227.02203+0.0)x256.47481
+.\hbox(227.02203+0.0)x256.47481
+..\glue 114.01103
+..\vbox(0.0+0.0)x0.0, shifted -84.55826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\special{pdf:literal 0 28.34647 28.34647 28.34647 28.34647 56.69292 c}
+...\special{pdf:literal S}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
More information about the latex3-commits
mailing list