summaryrefslogtreecommitdiff
path: root/graphics/pgf
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf')
-rw-r--r--graphics/pgf/contrib/liftarm/README.md22
-rw-r--r--graphics/pgf/contrib/liftarm/liftarm.pdfbin4095932 -> 2004786 bytes
-rw-r--r--graphics/pgf/contrib/liftarm/liftarm.sty132
-rw-r--r--graphics/pgf/contrib/liftarm/liftarm.tex142
4 files changed, 224 insertions, 72 deletions
diff --git a/graphics/pgf/contrib/liftarm/README.md b/graphics/pgf/contrib/liftarm/README.md
index fc982a486f..2759458717 100644
--- a/graphics/pgf/contrib/liftarm/README.md
+++ b/graphics/pgf/contrib/liftarm/README.md
@@ -2,8 +2,24 @@
Draw liftarms with TikZ
-(c) Matthias Floré
+Version 2.0 (2022/04/07)
-This package is based on the package TikZ and can be used to draw liftarms with TikZ. It provides several options for the appearance of the liftarms, a command which connects two liftarms and an environment to describe a construction.
+This package is based on the package TikZ and can be used to draw liftarms with TikZ. It provides several options for the appearance of the liftarms, a command which connects two liftarms, an environment to describe a construction and a method to animate a construction with one or more traces.
-This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives on http://www.latex-project.org/lppl.txt. \ No newline at end of file
+%% README.md
+%% Copyright 2022 Matthias Floré
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Matthias Floré.
+%
+% This work consists of the files liftarm.pdf, liftarm.sty,
+% liftarm.tex and README.md. \ No newline at end of file
diff --git a/graphics/pgf/contrib/liftarm/liftarm.pdf b/graphics/pgf/contrib/liftarm/liftarm.pdf
index 73b4628baf..d428d1f7af 100644
--- a/graphics/pgf/contrib/liftarm/liftarm.pdf
+++ b/graphics/pgf/contrib/liftarm/liftarm.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/liftarm/liftarm.sty b/graphics/pgf/contrib/liftarm/liftarm.sty
index 9cd8660f8e..b850c8f16a 100644
--- a/graphics/pgf/contrib/liftarm/liftarm.sty
+++ b/graphics/pgf/contrib/liftarm/liftarm.sty
@@ -1,20 +1,36 @@
-%liftarm package
-%Draw liftarms with TikZ
-%(c) Matthias Floré
-%This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives on http://www.latex-project.org/lppl.txt.
+%% liftarm.sty
+%% Copyright 2022 Matthias Floré
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Matthias Floré.
+%
+% This work consists of the files liftarm.pdf, liftarm.sty,
+% liftarm.tex and README.md.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{liftarm}[2022/03/06 v1.0 Draw liftarms with TikZ]
+\ProvidesPackage{liftarm}[2022/04/07 v2.0 Draw liftarms with TikZ]
\RequirePackage{etoolbox}
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{tikz}
\usetikzlibrary{calc}
+\newif\ifliftarm@animate
\newif\ifliftarm@brick
-\newif\ifliftarm@contour
\newif\ifliftarm@connectreverse
+\newif\ifliftarm@contour
\pgfkeys{
/liftarm/.is family,
/liftarm/.unknown/.code={\edef\liftarm@colorkey{\pgfkeyscurrentname}},
/liftarm,
+axle holes/.store in=\liftarm@axleholes,
+brick/.is if=liftarm@brick,
color/.store in=\liftarm@colorkey,
color 0/.initial=Gray,
color 1/.initial=darkgray,
@@ -25,27 +41,26 @@ color 5/.initial=Green,
color 6/.initial=Blue,
color 7/.initial=Brown,
color modulo/.initial=8,
-brick/.is if=liftarm@brick,
-axle holes/.store in=\liftarm@axleholes,
-mark holes/.store in=\liftarm@markholes,
-mark color/.initial=Black,
-screw holes/.store in=\liftarm@screwholes,
-screw holes angle/.initial=45,
-screw color/.initial=Black,
-scalefactor/.initial=0.5,
+connect/.store in=\liftarm@connect,
+connect coordinate/.store in=\liftarm@connectcoordinate,
+connect reverse/.is if=liftarm@connectreverse,
contour/.is if=liftarm@contour,
coordinate/.store in=\liftarm@coordinate,
-connect coordinate/.store in=\liftarm@connectcoordinate,
-connect/.store in=\liftarm@connect,
globalize/.code n args={2}{\xdef#1{#2}},
-liftarm 1 options/.style={},
+hole radius/.initial=0.3,
liftarm 1/.style={liftarm 1 options/.style={#1}},
-liftarm 2 options/.style={},
+liftarm 1 options/.style={},
liftarm 2/.style={liftarm 2 options/.style={#1}},
-origin/.initial=0,
-connect reverse/.is if=liftarm@connectreverse,
-hole radius/.initial=0.3,
+liftarm 2 options/.style={},
liftarm thickness/.initial=0.92,
+mark color/.initial=Black,
+mark holes/.store in=\liftarm@markholes,
+origin/.initial=0,
+scalefactor/.initial=0.5,
+screw color/.initial=Black,
+screw holes/.store in=\liftarm@screwholes,
+screw holes angle/.initial=45,
+trace/.store in=\liftarm@trace,
}
\pgfmathsetmacro{\liftarm@axleholeangle}{14}%2*\liftarm@axleholeradius*sin(\liftarm@axleholeangle)=1.78/8
\pgfmathsetmacro{\liftarm@screwholestartangle}{10}
@@ -145,6 +160,32 @@ liftarm thickness/.initial=0.92,
\coordinate (\liftarm@name) at (\liftarm@value,0);
}
\fi
+\ifcsname liftarm@trace\endcsname
+\ifliftarm@animate
+\foreach\liftarm@n/\liftarm@numberofframes/\liftarm@tracefigure in \liftarm@trace{
+\pgfmathsetmacro{\liftarm@value}{\liftarm@n}
+\gappto\liftarm@animateframestrace{\newframe\begin{scope}}
+\addtocounter{liftarm@animateframenumber}{1}
+\xappto\liftarm@animateframestrace{[shift={(#2)},rotate=\liftarm@ang]}
+\gappto\liftarm@animateframestrace{\begin{scope}}
+\xappto\liftarm@animateframestrace{[shift={(\liftarm@value-\liftarm@origin,0)}]}
+\ifdefempty{\liftarm@tracefigure}{
+\gappto\liftarm@animateframestrace{\fill[Black] (0,0) circle}
+\xappto\liftarm@animateframestrace{[radius=0.66*\liftarm@holeradius];}
+}
+{
+\xappto\liftarm@animateframestrace{\expandonce\liftarm@tracefigure}
+}
+\gappto\liftarm@animateframestrace{\end{scope}\end{scope}}
+\ifdefempty{\liftarm@numberofframes}{
+\csxappto{liftarm@animatetimeline0}{\theliftarm@animateframenumber x0,}
+}
+{
+\csxappto{liftarm@animatetimeline\theliftarm@animatestepnumber}{\theliftarm@animateframenumber x\liftarm@numberofframes,}
+}
+}
+\fi
+\fi
\end{scope}
\end{scope}
\fi
@@ -194,11 +235,11 @@ in
/liftarm/globalize={\liftarm@connectyblet}{\n2}
]
;
-\pgfmathsetmacro{\liftarm@connectxa}{\liftarm@connectxalet};
-\pgfmathsetmacro{\liftarm@connectya}{\liftarm@connectyalet};
-\pgfmathsetmacro{\liftarm@connectxb}{\liftarm@connectxblet};
-\pgfmathsetmacro{\liftarm@connectyb}{\liftarm@connectyblet};
-\pgfmathsetmacro{\liftarm@absdiff}{abs(\liftarm@connectxa-\liftarm@connectxb)};
+\pgfmathsetmacro{\liftarm@connectxa}{\liftarm@connectxalet}
+\pgfmathsetmacro{\liftarm@connectya}{\liftarm@connectyalet}
+\pgfmathsetmacro{\liftarm@connectxb}{\liftarm@connectxblet}
+\pgfmathsetmacro{\liftarm@connectyb}{\liftarm@connectyblet}
+\pgfmathsetmacro{\liftarm@absdiff}{abs(\liftarm@connectxa-\liftarm@connectxb)}
\ifdim \liftarm@absdiff pt<0.001 pt
\pgfmathsetmacro{\liftarm@connectanglegamma}{90}
\ifdim \liftarm@connectya pt<\liftarm@connectyb pt
@@ -253,4 +294,43 @@ in
\expandafter\liftarm@construction\expandafter[\liftarm@constructoptions]{#1}
}
\newenvironment{liftarmconstruction}[1][]{\def\liftarm@constructoptions{#1}\def\liftarm@constructfigure{}\begin{enumerate}}{\end{enumerate}}
+\newcounter{liftarm@animatenumberofsteps}
+\newcounter{liftarm@animateframenumber}
+\newcounter{liftarm@animatestepnumber}
+\newwrite\liftarm@animatewritetimeline
+\newcounter{liftarm@animatenumberofanimation}
+\newcommand{\liftarmanimate}[4][]{%
+\liftarm@animatetrue%
+\addtocounter{liftarm@animatenumberofanimation}{1}%
+\setcounter{liftarm@animatenumberofsteps}{-1}%
+\gdef\liftarm@animateframes{}%
+\gdef\liftarm@animateframestrace{}%
+\setcounter{liftarm@animatestepnumber}{-1}%
+\foreach\liftarm@n in {#3}{%
+\addtocounter{liftarm@animatenumberofsteps}{1}%
+\gappto\liftarm@animateframes{\newframe\addtocounter{liftarm@animatestepnumber}{1}#4}%
+\xappto\liftarm@animateframes{{\liftarm@n}}%
+}%
+\patchcmd{\liftarm@animateframes}{\newframe}{}{}{}%
+\csgdef{liftarm@animatetimeline0}{c,}%
+\foreach\liftarm@n in {1,...,\theliftarm@animatenumberofsteps}{%
+\csgdef{liftarm@animatetimeline\liftarm@n}{}%
+}%
+\setcounter{liftarm@animateframenumber}{\theliftarm@animatenumberofsteps}%
+\IfFileExists{\jobname\theliftarm@animatenumberofanimation.tln}{}{%
+\immediate\openout\liftarm@animatewritetimeline=\jobname\theliftarm@animatenumberofanimation.tln%
+\immediate\write\liftarm@animatewritetimeline{::c,0}%
+\immediate\closeout\liftarm@animatewritetimeline%
+}%
+\begin{animateinline}[#1,timeline=\jobname\theliftarm@animatenumberofanimation.tln]{#2}%
+\liftarm@animateframes%
+\liftarm@animateframestrace%
+\end{animateinline}%
+\immediate\openout\liftarm@animatewritetimeline=\jobname\theliftarm@animatenumberofanimation.tln%
+\foreach\liftarm@n in {0,...,\theliftarm@animatenumberofsteps}{%
+\immediate\write\liftarm@animatewritetimeline{::\csname liftarm@animatetimeline\liftarm@n\endcsname\liftarm@n}%
+}%
+\immediate\closeout\liftarm@animatewritetimeline%
+\liftarm@animatefalse%
+}
\endinput \ No newline at end of file
diff --git a/graphics/pgf/contrib/liftarm/liftarm.tex b/graphics/pgf/contrib/liftarm/liftarm.tex
index 8619b58f2d..b45bb85793 100644
--- a/graphics/pgf/contrib/liftarm/liftarm.tex
+++ b/graphics/pgf/contrib/liftarm/liftarm.tex
@@ -1,7 +1,20 @@
-%Documentation for the liftarm package
-%Draw liftarms with TikZ
-%(c) Matthias Floré
-%This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives on http://www.latex-project.org/lppl.txt.
+%% liftarm.tex
+%% Copyright 2022 Matthias Floré
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Matthias Floré.
+%
+% This work consists of the files liftarm.pdf, liftarm.sty,
+% liftarm.tex and README.md.
\documentclass[a4paper,english,dvipsnames]{ltxdoc}
\usepackage[english]{babel}
\usepackage{graphicx}
@@ -32,21 +45,19 @@
\DeclareMathOperator{\atan}{atan}
\title{The \texttt{liftarm} package\\[12pt]\large Draw liftarms with \tikzname}
\author{Matthias Flor\'e}
-\date{2022-03-08}
+\date{Version 2.0 (2022/04/07)}%\\[12pt]
\begin{document}
\maketitle
\thispagestyle{fancy}
\begin{abstract}
-\noindent This package is based on the package |tikz| (see \cite{TtTaPGFp}) and can be used to draw liftarms with \tikzname. It provides several options for the appearance of the liftarms, a command which connects two liftarms and an environment to describe a construction. This is the manual for version 1.0.
+\noindent This package is based on the package |tikz| (see \cite{TtTaPGFp}) and can be used to draw liftarms with \tikzname. It provides several options for the appearance of the liftarms, a command which connects two liftarms, an environment to describe a construction and a method to animate a construction with one or more traces.% This is the manual for version .
\end{abstract}
\tableofcontents
\section{Usage}
-The package |liftarm| can be used by putting
-
-|\usepackage{liftarm}|
-
-in the preamble.
-
+The package |liftarm| can be used by putting the following in the preamble.
+\begin{codeexample}[code only]
+\usepackage{liftarm}
+\end{codeexample}
The package |liftarm| loads the packages |etoolbox|, |xcolor| with the option |dvipsnames|, |tikz| and the \tikzname{} library |calc|. Since |xcolor| is loaded with the option |dvipsnames|, packages such as |pgfplots| and |tcolorbox| must be loaded \emph{after} |liftarm|.
\section{Drawing liftarms}
\begin{command}{\liftarm\opt{\oarg{options}}\marg{point}\marg{length}\marg{angle}}
@@ -373,6 +384,49 @@ As an example, we describe below the construction of a regular pentagon from \ci
\end{codeexample}
\end{command}
\end{environment}
+\section{Animations}
+\begin{command}{\liftarmanimate\opt{\oarg{options}}\marg{frame rate}\marg{list}\marg{command}}
+This command shows an animation using the |animateinline| environment of the package |animate|. The package |animate| is \emph{not} loaded by default and needs to be loaded to use the command |\liftarmanimate|. The \meta{options} are passed to the |animateinline| environment. The \meta{frame rate} of the animation is described in the documentation of the package |animate|. The \meta{command} must be a previously defined command with one mandatory argument. The \meta{list} is passed to a |\foreach| loop. The frames of the animation consist of the \meta{command} evaluated one by one in the result of the |\foreach| loop. The command |\liftarmanimate| creates a timeline which is used in the |animateinline| environment. This timeline is stored in the file |liftarm|\meta{number of the animation in the document}|.tln|. It requires two compiler runs to create and use this timeline correctly.
+\begin{key}{/liftarm/trace=\marg{number/number of frames/code}\dots}
+This key draws \meta{code} at hole \meta{number} of the liftarm on the frames of the animation determined by \meta{number of frames}.
+
+If \meta{number of frames} is 0 then the \meta{code} is drawn starting at the current frame until the end of the animation. If \meta{number of frames} is an integer greater than or equal to 1 then the \meta{code} is drawn starting at the current frame and remaining during the next frames determined by \meta{number of frames}. If \meta{number of frames} is left empty then the \meta{code} is drawn starting at the beginning of the animation until the end of the animation.
+
+The \meta{code} can be some \tikzname{} code. In this \meta{code}, $(0,0)$ is positioned at hole \meta{number} of the liftarm. If \meta{code} is left empty then the following code is used.
+\begin{codeexample}[code only]
+\fill[Black] (0,0) circle[radius=0.66*\liftarm@holeradius];
+\end{codeexample}
+A list of multiple triples \meta{number/number of frames/code} can be given to the key |trace|.
+\begin{codeexample}[width=10cm,preamble={\usepackage{animate}}]
+\newcommand{\exampleliftarmanimate}[1]{
+ \liftarm[
+ origin=1,
+ mark holes=1,
+ trace={
+ 2/0/,
+ 3//,
+ 4/3/{\fill[Blue] (0,0)
+ circle[radius=0.15];}
+ }
+ ]{0,0}{4}{#1}
+}
+\liftarmanimate[
+ autoplay,
+ controls,
+ loop,
+ begin={
+ \begin{tikzpicture}
+ \useasboundingbox (-4,-4)
+ rectangle (4,4);
+ },
+ end={\end{tikzpicture}}
+]
+{5}
+{0,30,...,330}
+{\exampleliftarmanimate}
+\end{codeexample}
+\end{key}
+\end{command}
\section{Additional examples}
The following example shows a regular hexagon.
\begin{codeexample}[width=9cm]
@@ -430,13 +484,14 @@ The following example illustrates that $7^{2}+4^{2}=8^{2}+1^{2}$.
%\liftarm{0,0}{\b}{0}
%\liftarm{\b,0}{\a}{90}
\liftarmconnect{0,0}{\b}{\b,\a}{\a}
+\liftarm{4,0}{3}{90}
%\liftarm{\b,\a}{1}{atan(\a/\b)+atan(\c/\d)+90}
%\liftarm{0,0}{\d}{atan(\a/\b)+atan(\c/\d)}
\liftarmconnect{\b,\a}{\c}{0,0}{\d}
\end{tikzpicture}
\end{codeexample}
Below is an animation of the Peaucellier-Lipkin linkage, see e.g.~\cite{Koagmopermbl}.
-\begin{codeexample}[width=9cm]
+\begin{codeexample}[width=9cm,preamble={\usepackage{animate}}]
\newcommand{\PLlinkage}[1]{
\begin{tikzpicture}[scale=0.75]
\def\a{3}
@@ -463,19 +518,15 @@ Below is an animation of the Peaucellier-Lipkin linkage, see e.g.~\cite{Koagmope
\begin{animateinline}[
autoplay,
controls,
- loop
+ palindrome
]{30}
-\multiframe{80}{rXmax=-40+1}{
- \PLlinkage{\rXmax}
-}
-\newframe
-\multiframe{80}{rXmax=-40+1}{
- \PLlinkage{-\rXmax}
+\multiframe{80}{rAng=-40+1}{
+ \PLlinkage{\rAng}
}
\end{animateinline}
\end{codeexample}
Below is an animation of Kempe's trisector, as shown in \cite{Tmm3}.
-\begin{codeexample}[]
+\begin{codeexample}[preamble={\usepackage{animate}}]
\newcommand{\trisector}[1]{
\begin{tikzpicture}[scale=0.33]
\useasboundingbox (-27.3,-0.5) rectangle (21.2,37);
@@ -487,23 +538,15 @@ Below is an animation of Kempe's trisector, as shown in \cite{Tmm3}.
\liftarmconnect[liftarm 2={connect=8}]{A}{12}{B}{18}
\end{tikzpicture}
}
-\begin{animateinline}[autoplay,controls,loop]{5}
-\multiframe{20}{rXmax=0+1}{
-\trisector{15+\rXmax}
-}
-\newframe
-\multiframe{20}{rXmax=0+1}{
-\trisector{35-\rXmax}
+\begin{animateinline}[autoplay,controls,palindrome]{5}
+\multiframe{20}{rAng=15+1}{
+\trisector{\rAng}
}
\end{animateinline}
\end{codeexample}
Below is an animation of Chebyshev's Lambda Mechanism.
-\begin{codeexample}[width=10cm]
+\begin{codeexample}[width=10cm,preamble={\usepackage{animate}}]
\newcommand{\CL}[1]{
-\begin{tikzpicture}[scale=0.8]
-\def\r{1}
-\useasboundingbox (-2*\r-0.5,-2*\r-0.5)
- rectangle (10*\r-0.5,10*\r+0.5);
\liftarm{0,0}{4*\r}{0}
\liftarm[
mark holes={0,2*\r}
@@ -513,21 +556,34 @@ Below is an animation of Chebyshev's Lambda Mechanism.
liftarm 2={
connect=5*\r,
mark holes=10*\r,
- mark color=Red
+ mark color=Red,
+ trace={6*\r/0/,10*\r//}
}
]{4*\r,0}{5*\r}{#1:2*\r}{10*\r}
-\end{tikzpicture}
}
-\begin{animateinline}[
+\liftarmanimate[
autoplay,
controls,
- loop
-]{60}
-\multiframe{360}{rXmax=0+1}{
- \CL{\rXmax}
-}
-\end{animateinline}
+ loop,
+ begin={
+ \begin{tikzpicture}[scale=0.8]
+ \def\r{1}
+ \useasboundingbox
+ (-2*\r-0.5,-2*\r-0.5)
+ rectangle
+ (10*\r-0.5,10*\r+0.5);
+ },
+ end={\end{tikzpicture}}
+]
+{20}
+{0,5,...,355}
+{\CL}
\end{codeexample}
+\section{Version history}
+\begin{itemize}
+\item[] \textbf{Version 1.0 (2022/03/08)} First version.
+\item[] \textbf{Version 2.0 (2022/04/07)} Removed some redundant |;| in the code.\footnote{Thanks to Denis Bitouz\'e for pointing this out.} Added the command |\liftarmanimate| and the key |trace|.
+\end{itemize}
\begin{thebibliography}{9}
\bibitem{Tmm1}
Gerard 't Hooft,
@@ -552,7 +608,7 @@ Alfred Bray Kempe,
Till Tantau,
\emph{The \tikzname{} and {\upshape\pgfname} Packages},
Manual for version 3.1.9a,
-\url{https://www.ctan.org/pkg/pgf},
+\url{https://ctan.org/pkg/pgf},
2021.
\end{thebibliography}
\printindex