[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: One-point curve (b370e3e)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Feb 15 22:35:01 CET 2018


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

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

commit b370e3e93cd0cde9baf8d259a93526687891fd46
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Feb 15 21:26:51 2018 +0000

    l3draw: One-point curve


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

b370e3e93cd0cde9baf8d259a93526687891fd46
 l3trial/l3draw/l3draw-paths.dtx              |   78 ++++++++++++++++++++++++++
 l3trial/l3draw/l3draw.dtx                    |    6 ++
 l3trial/l3draw/testfiles/m3draw003.lvt       |   10 ++++
 l3trial/l3draw/testfiles/m3draw003.ptex.tlg  |   16 ++++++
 l3trial/l3draw/testfiles/m3draw003.tlg       |   16 ++++++
 l3trial/l3draw/testfiles/m3draw003.uptex.tlg |   16 ++++++
 l3trial/l3draw/testfiles/m3draw003.xetex.tlg |   16 ++++++
 7 files changed, 158 insertions(+)

diff --git a/l3trial/l3draw/l3draw-paths.dtx b/l3trial/l3draw/l3draw-paths.dtx
index 8c622d2..7a33c3d 100644
--- a/l3trial/l3draw/l3draw-paths.dtx
+++ b/l3trial/l3draw/l3draw-paths.dtx
@@ -58,6 +58,14 @@
 %<@@=draw>
 %    \end{macrocode}
 %
+% \begin{variable}{\l_@@_path_tmp_fp, \l_@@_path_tmp_fp}
+%   Scratch space.
+%    \begin{macrocode}
+\fp_new:N \l_@@_path_xtmp_fp
+\fp_new:N \l_@@_path_ytmp_fp
+%    \end{macrocode}
+% \end{variable}
+%
 % \subsection{Tracking paths}
 %
 % \begin{variable}{\g_@@_path_lastx_dim, \g_@@_path_lasty_dim}
@@ -265,6 +273,76 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{Computed curves}
+%
+% More complex operations need some calculations. To assist with those, various
+% constants are pre-defined.
+%
+% \begin{macro}{\draw_path_curveto:nn}
+% \begin{macro}{\@@_path_curveto:nnnn}
+% \begin{variable}{\c_@@_path_curveto_a_fp, \c_@@_path_curveto_b_fp}
+%   A quadratic curve with one control point $(x_{\mathrm{c}},
+%   y_{\mathrm{c}})$. The two required control points are then
+%   \[
+%     x_{1} = \frac{1}{3}x_{\mathrm{s}} + \frac{2}{3}x_{\mathrm{c}}
+%     \quad
+%     y_{1} = \frac{1}{3}y_{\mathrm{s}} + \frac{2}{3}y_{\mathrm{c}}
+%   \]
+%   and
+%   \[
+%     x_{2} = \frac{1}{3}x_{\mathrm{e}} + \frac{2}{3}x_{\mathrm{c}}
+%     \quad
+%     x_{2} = \frac{1}{3}y_{\mathrm{e}} + \frac{2}{3}y_{\mathrm{c}}
+%   \]
+%   using the start (last) point $(x_{\mathrm{s}}, y_{\mathrm{s}})$
+%   and the end point $(x_{\mathrm{s}}, y_{\mathrm{s}})$.
+%    \begin{macrocode}
+\cs_new_protected:Npn \draw_path_curveto:nn #1#2
+  {
+    \@@_point_process:nnn
+      { \@@_path_curveto:nnnn }
+      { \draw_point_transform:n {#1} }
+      { \draw_point_transform:n {#2} }
+  }
+\cs_new_protected:Npn \@@_path_curveto:nnnn #1#2#3#4
+  {
+    \fp_set:Nn \l_@@_path_xtmp_fp { \c_@@_path_curveto_b_fp * #1 }
+    \fp_set:Nn \l_@@_path_ytmp_fp { \c_@@_path_curveto_b_fp * #2 }
+    \use:x
+      {
+         \@@_path_curveto:nnnnnn
+           {
+             \fp_to_dim:n
+               {
+                   \c_@@_path_curveto_a_fp * \g_@@_path_lastx_dim
+                 + \l_@@_path_xtmp_fp
+               }
+           }
+           {
+             \fp_to_dim:n
+               {
+                   \c_@@_path_curveto_a_fp * \g_@@_path_lasty_dim
+                 + \l_@@_path_ytmp_fp
+               }
+           }
+           {
+             \fp_to_dim:n
+               { \c_@@_path_curveto_a_fp * #3 + \l_@@_path_xtmp_fp }
+           }
+           {
+             \fp_to_dim:n
+               { \c_@@_path_curveto_a_fp * #4 + \l_@@_path_ytmp_fp }
+           }
+           {#3}
+           {#4}
+      }
+  }
+\fp_const:Nn \c_@@_path_curveto_a_fp { 1 / 3 }
+\fp_const:Nn \c_@@_path_curveto_b_fp { 2 / 3 }
+%    \end{macrocode}
+% \end{variable}
+% \end{macro}
+% \end{macro}
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index 4f2f9dc..68beb09 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -239,6 +239,12 @@
 %   \end{syntax}
 % \end{function}
 %
+% \begin{function}{\draw_path_curveto:nn}
+%   \begin{syntax}
+%     \cs{draw_path_curveto:nn} \Arg{point expr1} \Arg{point expr2}
+%   \end{syntax}
+% \end{function}
+%
 % \begin{function}{\draw_path_close:}
 %   \begin{syntax}
 %     \cs{draw_path_close:}
diff --git a/l3trial/l3draw/testfiles/m3draw003.lvt b/l3trial/l3draw/testfiles/m3draw003.lvt
index 0a762be..927eac1 100644
--- a/l3trial/l3draw/testfiles/m3draw003.lvt
+++ b/l3trial/l3draw/testfiles/m3draw003.lvt
@@ -64,4 +64,14 @@
       }
   }
 
+\TEST { \draw_path_curveto:nnn }
+  {
+    \test:n
+      {
+        \draw_path_curveto:nn
+          { \draw_point_vec:nn { 1 } { 1 } }
+          { \draw_point_vec:nn { 1 } { 2 } }
+      }
+  }
+
 \END
diff --git a/l3trial/l3draw/testfiles/m3draw003.ptex.tlg b/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
index a8a3cb7..27ebdff 100644
--- a/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
@@ -68,3 +68,19 @@ TEST 4: \draw_path_close:
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 5: \draw_path_curveto:nnn 
+============================================================
+> \box...=
+\hbox(76.20735+0.0)x9.48425
+.\hbox(76.20735+0.0)x9.48425
+..\glue -18.9685
+..\hbox(0.0+0.0)x0.0, shifted 19.30183
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 18.89764 19.22972 28.34647 37.79527 28.34647 56.69292 c}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3trial/l3draw/testfiles/m3draw003.tlg b/l3trial/l3draw/testfiles/m3draw003.tlg
index 044c245..bd8d210 100644
--- a/l3trial/l3draw/testfiles/m3draw003.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.tlg
@@ -68,3 +68,19 @@ TEST 4: \draw_path_close:
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 5: \draw_path_curveto:nnn 
+============================================================
+> \box...=
+\hbox(76.20735+0.0)x9.48425
+.\hbox(76.20735+0.0)x9.48425
+..\glue -18.9685
+..\hbox(0.0+0.0)x0.0, shifted 19.30183
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{18.89764 19.22972 28.34647 37.79527 28.34647 56.69292 c}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3trial/l3draw/testfiles/m3draw003.uptex.tlg b/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
index a8a3cb7..27ebdff 100644
--- a/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
@@ -68,3 +68,19 @@ TEST 4: \draw_path_close:
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 5: \draw_path_curveto:nnn 
+============================================================
+> \box...=
+\hbox(76.20735+0.0)x9.48425
+.\hbox(76.20735+0.0)x9.48425
+..\glue -18.9685
+..\hbox(0.0+0.0)x0.0, shifted 19.30183
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 18.89764 19.22972 28.34647 37.79527 28.34647 56.69292 c}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================
diff --git a/l3trial/l3draw/testfiles/m3draw003.xetex.tlg b/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
index a8a3cb7..27ebdff 100644
--- a/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
@@ -68,3 +68,19 @@ TEST 4: \draw_path_close:
 <argument> \l_tmpa_box 
 l. ...  }
 ============================================================
+============================================================
+TEST 5: \draw_path_curveto:nnn 
+============================================================
+> \box...=
+\hbox(76.20735+0.0)x9.48425
+.\hbox(76.20735+0.0)x9.48425
+..\glue -18.9685
+..\hbox(0.0+0.0)x0.0, shifted 19.30183
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 18.89764 19.22972 28.34647 37.79527 28.34647 56.69292 c}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box 
+l. ...  }
+============================================================





More information about the latex3-commits mailing list