[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: Ellipses and circles (0c68c2b)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sat Feb 17 19:37:57 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/0c68c2b059a728b90e29637f01fd510a992808cc
>---------------------------------------------------------------
commit 0c68c2b059a728b90e29637f01fd510a992808cc
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Sat Feb 17 18:37:57 2018 +0000
l3draw: Ellipses and circles
>---------------------------------------------------------------
0c68c2b059a728b90e29637f01fd510a992808cc
l3trial/l3draw/l3draw-paths.dtx | 94 ++++++++++++++++++++++++++
l3trial/l3draw/l3draw.dtx | 12 ++++
l3trial/l3draw/testfiles/m3draw003.lvt | 20 ++++++
l3trial/l3draw/testfiles/m3draw003.ptex.tlg | 62 +++++++++++++++++
l3trial/l3draw/testfiles/m3draw003.tlg | 62 +++++++++++++++++
l3trial/l3draw/testfiles/m3draw003.uptex.tlg | 62 +++++++++++++++++
l3trial/l3draw/testfiles/m3draw003.xetex.tlg | 62 +++++++++++++++++
7 files changed, 374 insertions(+)
diff --git a/l3trial/l3draw/l3draw-paths.dtx b/l3trial/l3draw/l3draw-paths.dtx
index fca7475..ea49612 100644
--- a/l3trial/l3draw/l3draw-paths.dtx
+++ b/l3trial/l3draw/l3draw-paths.dtx
@@ -576,6 +576,100 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\draw_path_ellipse:nnn}
+% \begin{macro}{\@@_path_ellipse:nnnnnn}
+% \begin{macro}[EXP]
+% {
+% \@@_path_ellipse_arci:nnnnnn ,
+% \@@_path_ellipse_arcii:nnnnnn ,
+% \@@_path_ellipse_arciii:nnnnnn ,
+% \@@_path_ellipse_arciv:nnnnnn
+% }
+% Drawing an ellipse is an optimised version of drawing an arc, in particular
+% reusing the same constant. We need to deal with the ellipse in four parts
+% and also deal with moving to the right place, closing it and ending up
+% back at the center. That is handled on a per-arc basis, each in a
+% separate auxiliary for readability.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_path_ellipse:nnn #1#2#3
+ {
+ \@@_point_process:nnn
+ {
+ \@@_point_process:nn
+ { \@@_path_ellipse:nnnnnn }
+ { \draw_point_transform:n {#1} }
+ }
+ { \@@_point_transform_noshift:n {#2} }
+ { \@@_point_transform_noshift:n {#3} }
+ }
+\cs_new_protected:Npn \@@_path_ellipse:nnnnnn #1#2#3#4#5#6
+ {
+ \use:x
+ {
+ \@@_path_moveto:nn
+ { \fp_to_dim:n { #1 + #3 } } { \fp_to_dim:n { #2 + #4 } }
+ \@@_path_ellipse_arci:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6}
+ \@@_path_ellipse_arcii:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6}
+ \@@_path_ellipse_arciii:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6}
+ \@@_path_ellipse_arciv:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6}
+ }
+ \@@_softpath_closepath:
+ \@@_path_moveto:nn {#1} {#2}
+ }
+\cs_new:Npn \@@_path_ellipse_arci:nnnnnn #1#2#3#4#5#6
+ {
+ \@@_path_curveto:nnnnnn
+ { \fp_to_dim:n { #1 + #3 + #5 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #2 + #4 + #6 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #1 + #3 * \c_@@_path_ellipse_fp + #5 } }
+ { \fp_to_dim:n { #2 + #4 * \c_@@_path_ellipse_fp + #6 } }
+ { \fp_to_dim:n { #1 + #5 } }
+ { \fp_to_dim:n { #2 + #6 } }
+ }
+\cs_new:Npn \@@_path_ellipse_arcii:nnnnnn #1#2#3#4#5#6
+ {
+ \@@_path_curveto:nnnnnn
+ { \fp_to_dim:n { #1 - #3 * \c_@@_path_ellipse_fp + #5 } }
+ { \fp_to_dim:n { #2 - #4 * \c_@@_path_ellipse_fp + #6 } }
+ { \fp_to_dim:n { #1 - #3 + #5 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #2 - #4 + #6 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #1 - #3 } }
+ { \fp_to_dim:n { #2 - #4 } }
+ }
+\cs_new:Npn \@@_path_ellipse_arciii:nnnnnn #1#2#3#4#5#6
+ {
+ \@@_path_curveto:nnnnnn
+ { \fp_to_dim:n { #1 - #3 - #5 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #2 - #4 - #6 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #1 - #3 * \c_@@_path_ellipse_fp - #5 } }
+ { \fp_to_dim:n { #2 - #4 * \c_@@_path_ellipse_fp - #6 } }
+ { \fp_to_dim:n { #1 - #5 } }
+ { \fp_to_dim:n { #2 - #6 } }
+ }
+\cs_new:Npn \@@_path_ellipse_arciv:nnnnnn #1#2#3#4#5#6
+ {
+ \@@_path_curveto:nnnnnn
+ { \fp_to_dim:n { #1 + #3 * \c_@@_path_ellipse_fp - #5 } }
+ { \fp_to_dim:n { #2 + #4 * \c_@@_path_ellipse_fp - #6 } }
+ { \fp_to_dim:n { #1 + #3 - #5 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #2 + #4 - #6 * \c_@@_path_ellipse_fp } }
+ { \fp_to_dim:n { #1 + #3 } }
+ { \fp_to_dim:n { #2 + #4 } }
+ }
+\fp_const:Nn \c_@@_path_ellipse_fp { \fp_use:c { c_@@_path_arc_90_fp } }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\draw_path_circle:nn}
+% A shortcut.
+% \begin{macrocode}
+\cs_new_protected:Npn \draw_path_circle:nn #1#2
+ { \draw_path_ellipse:nnn {#1} { #2 , 0pt } { 0pt , #2 } }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index f995dc7..fa0abc4 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -263,6 +263,18 @@
% \end{syntax}
% \end{function}
%
+% \begin{function}{\draw_path_ellipse:nnnn}
+% \begin{syntax}
+% \cs{draw_path_ellipse:nnn} \Arg{center} \Arg{axes1} \Arg{axis2}
+% \end{syntax}
+% \end{function}
+%
+% \begin{function}{\draw_path_cicle:nn}
+% \begin{syntax}
+% \cs{draw_path_cicle:nn} \Arg{center} \arg{radius}
+% \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 4400efb..65e082c 100644
--- a/l3trial/l3draw/testfiles/m3draw003.lvt
+++ b/l3trial/l3draw/testfiles/m3draw003.lvt
@@ -133,4 +133,24 @@
}
}
+\TEST { \draw_path_ellipse:nnn }
+ {
+ \test:n
+ {
+ \draw_path_ellipse:nnn { 1 , 1 } { 1 , 1 } { -2 , 2 }
+ }
+ \test:n
+ {
+ \draw_path_ellipse:nnn { 1cm , 0cm } { 1.5cm , 0cm } { 0cm , 1cm }
+ }
+ }
+
+\TEST { \draw_path_circle:nn }
+ {
+ \test:n
+ {
+ \draw_path_circle:nn { 1 , 1 } { 3cm }
+ }
+ }
+
\END
diff --git a/l3trial/l3draw/testfiles/m3draw003.ptex.tlg b/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
index ba3b0b0..81de56f 100644
--- a/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.ptex.tlg
@@ -233,3 +233,65 @@ TEST 7: \draw_path_arc_axes:nnnn
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 8: \draw_path_ellipse:nnn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x5.10458
+.\hbox(2.0+0.0)x5.10458
+..\glue 1.55229
+..\hbox(0.0+0.0)x0.0, shifted -1.55229
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 1.99252 1.99252 m}
+...\special{pdf:literal 0.89209 3.09297 -0.44603 3.53902 -0.99626 2.98878 c}
+...\special{pdf:literal -1.5465 2.43857 -1.10045 1.10045 0 0 c}
+...\special{pdf:literal 1.10045 -1.10045 2.43857 -1.5465 2.98878 -0.99626 c}
+...\special{pdf:literal 3.53902 -0.44603 3.09297 0.89209 1.99252 1.99252 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 0.99626 0.99626 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+> \box...=
+\hbox(0.0+0.0)x85.35828
+.\hbox(0.0+0.0)x85.35828
+..\glue 14.22638
+..\hbox(0.0+0.0)x0.0, shifted -28.45276
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 70.86615 0 m}
+...\special{pdf:literal 70.86615 15.65532 51.82942 28.34647 28.34647 28.34647 c}
+...\special{pdf:literal 4.86348 28.34647 -14.17323 15.65532 -14.17323 0 c}
+...\special{pdf:literal -14.17323 -15.65532 4.86348 -28.34647 28.34647 -28.34647 \ETC.}
+...\special{pdf:literal 51.82942 -28.34647 70.86615 -15.65532 70.86615 0 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 28.34647 0 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 9: \draw_path_circle:nn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x170.71652
+.\hbox(2.0+0.0)x170.71652
+..\glue 84.35826
+..\hbox(0.0+0.0)x0.0, shifted -84.35826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 86.03563 0.99626 m}
+...\special{pdf:literal 86.03563 47.96222 47.96222 86.03563 0.99626 86.03563 c}
+...\special{pdf:literal -45.96968 86.03563 -84.0431 47.96222 -84.0431 0.99626 c}
+...\special{pdf:literal -84.0431 -45.96968 -45.96968 -84.0431 0.99626 -84.0431 c}
+...\special{pdf:literal 47.96222 -84.0431 86.03563 -45.96968 86.03563 0.99626 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 0.99626 0.99626 m}
+...\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 7d02b06..234920e 100644
--- a/l3trial/l3draw/testfiles/m3draw003.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.tlg
@@ -233,3 +233,65 @@ TEST 7: \draw_path_arc_axes:nnnn
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 8: \draw_path_ellipse:nnn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x5.10458
+.\hbox(2.0+0.0)x5.10458
+..\glue 1.55229
+..\hbox(0.0+0.0)x0.0, shifted -1.55229
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{1.99252 1.99252 m}
+...\pdfliteral{0.89209 3.09297 -0.44603 3.53902 -0.99626 2.98878 c}
+...\pdfliteral{-1.5465 2.43857 -1.10045 1.10045 0 0 c}
+...\pdfliteral{1.10045 -1.10045 2.43857 -1.5465 2.98878 -0.99626 c}
+...\pdfliteral{3.53902 -0.44603 3.09297 0.89209 1.99252 1.99252 c}
+...\pdfliteral{h}
+...\pdfliteral{0.99626 0.99626 m}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+> \box...=
+\hbox(0.0+0.0)x85.35828
+.\hbox(0.0+0.0)x85.35828
+..\glue 14.22638
+..\hbox(0.0+0.0)x0.0, shifted -28.45276
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{70.86615 0 m}
+...\pdfliteral{70.86615 15.65532 51.82942 28.34647 28.34647 28.34647 c}
+...\pdfliteral{4.86348 28.34647 -14.17323 15.65532 -14.17323 0 c}
+...\pdfliteral{-14.17323 -15.65532 4.86348 -28.34647 28.34647 -28.34647 c}
+...\pdfliteral{51.82942 -28.34647 70.86615 -15.65532 70.86615 0 c}
+...\pdfliteral{h}
+...\pdfliteral{28.34647 0 m}
+...\pdfliteral{Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 9: \draw_path_circle:nn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x170.71652
+.\hbox(2.0+0.0)x170.71652
+..\glue 84.35826
+..\hbox(0.0+0.0)x0.0, shifted -84.35826
+...\pdfliteral{q}
+...\pdfliteral{0.3985 w}
+...\pdfliteral{86.03563 0.99626 m}
+...\pdfliteral{86.03563 47.96222 47.96222 86.03563 0.99626 86.03563 c}
+...\pdfliteral{-45.96968 86.03563 -84.0431 47.96222 -84.0431 0.99626 c}
+...\pdfliteral{-84.0431 -45.96968 -45.96968 -84.0431 0.99626 -84.0431 c}
+...\pdfliteral{47.96222 -84.0431 86.03563 -45.96968 86.03563 0.99626 c}
+...\pdfliteral{h}
+...\pdfliteral{0.99626 0.99626 m}
+...\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 ba3b0b0..81de56f 100644
--- a/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.uptex.tlg
@@ -233,3 +233,65 @@ TEST 7: \draw_path_arc_axes:nnnn
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 8: \draw_path_ellipse:nnn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x5.10458
+.\hbox(2.0+0.0)x5.10458
+..\glue 1.55229
+..\hbox(0.0+0.0)x0.0, shifted -1.55229
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 1.99252 1.99252 m}
+...\special{pdf:literal 0.89209 3.09297 -0.44603 3.53902 -0.99626 2.98878 c}
+...\special{pdf:literal -1.5465 2.43857 -1.10045 1.10045 0 0 c}
+...\special{pdf:literal 1.10045 -1.10045 2.43857 -1.5465 2.98878 -0.99626 c}
+...\special{pdf:literal 3.53902 -0.44603 3.09297 0.89209 1.99252 1.99252 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 0.99626 0.99626 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+> \box...=
+\hbox(0.0+0.0)x85.35828
+.\hbox(0.0+0.0)x85.35828
+..\glue 14.22638
+..\hbox(0.0+0.0)x0.0, shifted -28.45276
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 70.86615 0 m}
+...\special{pdf:literal 70.86615 15.65532 51.82942 28.34647 28.34647 28.34647 c}
+...\special{pdf:literal 4.86348 28.34647 -14.17323 15.65532 -14.17323 0 c}
+...\special{pdf:literal -14.17323 -15.65532 4.86348 -28.34647 28.34647 -28.34647 \ETC.}
+...\special{pdf:literal 51.82942 -28.34647 70.86615 -15.65532 70.86615 0 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 28.34647 0 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 9: \draw_path_circle:nn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x170.71652
+.\hbox(2.0+0.0)x170.71652
+..\glue 84.35826
+..\hbox(0.0+0.0)x0.0, shifted -84.35826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 86.03563 0.99626 m}
+...\special{pdf:literal 86.03563 47.96222 47.96222 86.03563 0.99626 86.03563 c}
+...\special{pdf:literal -45.96968 86.03563 -84.0431 47.96222 -84.0431 0.99626 c}
+...\special{pdf:literal -84.0431 -45.96968 -45.96968 -84.0431 0.99626 -84.0431 c}
+...\special{pdf:literal 47.96222 -84.0431 86.03563 -45.96968 86.03563 0.99626 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 0.99626 0.99626 m}
+...\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 ba3b0b0..81de56f 100644
--- a/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
+++ b/l3trial/l3draw/testfiles/m3draw003.xetex.tlg
@@ -233,3 +233,65 @@ TEST 7: \draw_path_arc_axes:nnnn
<argument> \l_tmpa_box
l. ... }
============================================================
+============================================================
+TEST 8: \draw_path_ellipse:nnn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x5.10458
+.\hbox(2.0+0.0)x5.10458
+..\glue 1.55229
+..\hbox(0.0+0.0)x0.0, shifted -1.55229
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 1.99252 1.99252 m}
+...\special{pdf:literal 0.89209 3.09297 -0.44603 3.53902 -0.99626 2.98878 c}
+...\special{pdf:literal -1.5465 2.43857 -1.10045 1.10045 0 0 c}
+...\special{pdf:literal 1.10045 -1.10045 2.43857 -1.5465 2.98878 -0.99626 c}
+...\special{pdf:literal 3.53902 -0.44603 3.09297 0.89209 1.99252 1.99252 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 0.99626 0.99626 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+> \box...=
+\hbox(0.0+0.0)x85.35828
+.\hbox(0.0+0.0)x85.35828
+..\glue 14.22638
+..\hbox(0.0+0.0)x0.0, shifted -28.45276
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 70.86615 0 m}
+...\special{pdf:literal 70.86615 15.65532 51.82942 28.34647 28.34647 28.34647 c}
+...\special{pdf:literal 4.86348 28.34647 -14.17323 15.65532 -14.17323 0 c}
+...\special{pdf:literal -14.17323 -15.65532 4.86348 -28.34647 28.34647 -28.34647 \ETC.}
+...\special{pdf:literal 51.82942 -28.34647 70.86615 -15.65532 70.86615 0 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 28.34647 0 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
+============================================================
+TEST 9: \draw_path_circle:nn
+============================================================
+> \box...=
+\hbox(2.0+0.0)x170.71652
+.\hbox(2.0+0.0)x170.71652
+..\glue 84.35826
+..\hbox(0.0+0.0)x0.0, shifted -84.35826
+...\special{pdf:literal q}
+...\special{pdf:literal 0.3985 w}
+...\special{pdf:literal 86.03563 0.99626 m}
+...\special{pdf:literal 86.03563 47.96222 47.96222 86.03563 0.99626 86.03563 c}
+...\special{pdf:literal -45.96968 86.03563 -84.0431 47.96222 -84.0431 0.99626 c}
+...\special{pdf:literal -84.0431 -45.96968 -45.96968 -84.0431 0.99626 -84.0431 c}
+...\special{pdf:literal 47.96222 -84.0431 86.03563 -45.96968 86.03563 0.99626 c}
+...\special{pdf:literal h}
+...\special{pdf:literal 0.99626 0.99626 m}
+...\special{pdf:literal Q}
+! OK.
+<argument> \l_tmpa_box
+l. ... }
+============================================================
More information about the latex3-commits
mailing list