texlive[62981] Master/texmf-dist: liftarm (8apr22)

commits+karl at tug.org commits+karl at tug.org
Fri Apr 8 23:43:56 CEST 2022


Revision: 62981
          http://tug.org/svn/texlive?view=revision&revision=62981
Author:   karl
Date:     2022-04-08 23:43:56 +0200 (Fri, 08 Apr 2022)
Log Message:
-----------
liftarm (8apr22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/liftarm/README.md
    trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.pdf
    trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex
    trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty

Modified: trunk/Master/texmf-dist/doc/latex/liftarm/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/liftarm/README.md	2022-04-08 21:43:40 UTC (rev 62980)
+++ trunk/Master/texmf-dist/doc/latex/liftarm/README.md	2022-04-08 21:43:56 UTC (rev 62981)
@@ -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

Modified: trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex	2022-04-08 21:43:40 UTC (rev 62980)
+++ trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex	2022-04-08 21:43:56 UTC (rev 62981)
@@ -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 @@
 \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 at 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,6 +484,7 @@
 %\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}
@@ -436,7 +491,7 @@
 \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 @@
 \begin{animateinline}[
     autoplay,
     controls,
-    loop
+    palindrome
 ]{30}
-\multiframe{80}{rXmax=-40+1}{
-    \PLlinkage{\rXmax}
+\multiframe{80}{rAng=-40+1}{
+    \PLlinkage{\rAng}
 }
-\newframe
-\multiframe{80}{rXmax=-40+1}{
-    \PLlinkage{-\rXmax}
-}
 \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 @@
 \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}
+\begin{animateinline}[autoplay,controls,palindrome]{5}
+\multiframe{20}{rAng=15+1}{
+\trisector{\rAng}
 }
-\newframe
-\multiframe{20}{rXmax=0+1}{
-\trisector{35-\rXmax}
-}
 \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 @@
     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 @@
 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

Modified: trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty	2022-04-08 21:43:40 UTC (rev 62980)
+++ trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty	2022-04-08 21:43:56 UTC (rev 62981)
@@ -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 at animate
 \newif\ifliftarm at brick
+\newif\ifliftarm at connectreverse
 \newif\ifliftarm at contour
-\newif\ifliftarm at connectreverse
 \pgfkeys{
 /liftarm/.is family,
 /liftarm/.unknown/.code={\edef\liftarm at colorkey{\pgfkeyscurrentname}},
 /liftarm,
+axle holes/.store in=\liftarm at axleholes,
+brick/.is if=liftarm at brick,
 color/.store in=\liftarm at colorkey,
 color 0/.initial=Gray,
 color 1/.initial=darkgray,
@@ -25,27 +41,26 @@
 color 6/.initial=Blue,
 color 7/.initial=Brown,
 color modulo/.initial=8,
-brick/.is if=liftarm at brick,
-axle holes/.store in=\liftarm at axleholes,
-mark holes/.store in=\liftarm at markholes,
-mark color/.initial=Black,
-screw holes/.store in=\liftarm at screwholes,
-screw holes angle/.initial=45,
-screw color/.initial=Black,
-scalefactor/.initial=0.5,
+connect/.store in=\liftarm at connect,
+connect coordinate/.store in=\liftarm at connectcoordinate,
+connect reverse/.is if=liftarm at connectreverse,
 contour/.is if=liftarm at contour,
 coordinate/.store in=\liftarm at coordinate,
-connect coordinate/.store in=\liftarm at connectcoordinate,
-connect/.store in=\liftarm at connect,
 globalize/.code n args={2}{\xdef#1{#2}},
+hole radius/.initial=0.3,
+liftarm 1/.style={liftarm 1 options/.style={#1}},
 liftarm 1 options/.style={},
-liftarm 1/.style={liftarm 1 options/.style={#1}},
+liftarm 2/.style={liftarm 2 options/.style={#1}},
 liftarm 2 options/.style={},
-liftarm 2/.style={liftarm 2 options/.style={#1}},
+liftarm thickness/.initial=0.92,
+mark color/.initial=Black,
+mark holes/.store in=\liftarm at markholes,
 origin/.initial=0,
-connect reverse/.is if=liftarm at connectreverse,
-hole radius/.initial=0.3,
-liftarm thickness/.initial=0.92,
+scalefactor/.initial=0.5,
+screw color/.initial=Black,
+screw holes/.store in=\liftarm at screwholes,
+screw holes angle/.initial=45,
+trace/.store in=\liftarm at trace,
 }
 \pgfmathsetmacro{\liftarm at axleholeangle}{14}%2*\liftarm at axleholeradius*sin(\liftarm at axleholeangle)=1.78/8
 \pgfmathsetmacro{\liftarm at screwholestartangle}{10}
@@ -145,6 +160,32 @@
 \coordinate (\liftarm at name) at (\liftarm at value,0);
 }
 \fi
+\ifcsname liftarm at trace\endcsname
+\ifliftarm at animate
+\foreach\liftarm at n/\liftarm at numberofframes/\liftarm at tracefigure in \liftarm at trace{
+\pgfmathsetmacro{\liftarm at value}{\liftarm at n}
+\gappto\liftarm at animateframestrace{\newframe\begin{scope}}
+\addtocounter{liftarm at animateframenumber}{1}
+\xappto\liftarm at animateframestrace{[shift={(#2)},rotate=\liftarm at ang]}
+\gappto\liftarm at animateframestrace{\begin{scope}}
+\xappto\liftarm at animateframestrace{[shift={(\liftarm at value-\liftarm at origin,0)}]}
+\ifdefempty{\liftarm at tracefigure}{
+\gappto\liftarm at animateframestrace{\fill[Black] (0,0) circle}
+\xappto\liftarm at animateframestrace{[radius=0.66*\liftarm at holeradius];}
+}
+{
+\xappto\liftarm at animateframestrace{\expandonce\liftarm at tracefigure}
+}
+\gappto\liftarm at animateframestrace{\end{scope}\end{scope}}
+\ifdefempty{\liftarm at numberofframes}{
+\csxappto{liftarm at animatetimeline0}{\theliftarm at animateframenumber x0,}
+}
+{
+\csxappto{liftarm at animatetimeline\theliftarm at animatestepnumber}{\theliftarm at animateframenumber x\liftarm at numberofframes,}
+}
+}
+\fi
+\fi
 \end{scope}
 \end{scope}
 \fi
@@ -194,11 +235,11 @@
 /liftarm/globalize={\liftarm at connectyblet}{\n2}
 ]
 ;
-\pgfmathsetmacro{\liftarm at connectxa}{\liftarm at connectxalet};
-\pgfmathsetmacro{\liftarm at connectya}{\liftarm at connectyalet};
-\pgfmathsetmacro{\liftarm at connectxb}{\liftarm at connectxblet};
-\pgfmathsetmacro{\liftarm at connectyb}{\liftarm at connectyblet};
-\pgfmathsetmacro{\liftarm at absdiff}{abs(\liftarm at connectxa-\liftarm at connectxb)};
+\pgfmathsetmacro{\liftarm at connectxa}{\liftarm at connectxalet}
+\pgfmathsetmacro{\liftarm at connectya}{\liftarm at connectyalet}
+\pgfmathsetmacro{\liftarm at connectxb}{\liftarm at connectxblet}
+\pgfmathsetmacro{\liftarm at connectyb}{\liftarm at connectyblet}
+\pgfmathsetmacro{\liftarm at absdiff}{abs(\liftarm at connectxa-\liftarm at connectxb)}
 \ifdim \liftarm at absdiff pt<0.001 pt
 \pgfmathsetmacro{\liftarm at connectanglegamma}{90}
 \ifdim \liftarm at connectya pt<\liftarm at connectyb pt
@@ -253,4 +294,43 @@
 \expandafter\liftarm at construction\expandafter[\liftarm at constructoptions]{#1}
 }
 \newenvironment{liftarmconstruction}[1][]{\def\liftarm at constructoptions{#1}\def\liftarm at constructfigure{}\begin{enumerate}}{\end{enumerate}}
+\newcounter{liftarm at animatenumberofsteps}
+\newcounter{liftarm at animateframenumber}
+\newcounter{liftarm at animatestepnumber}
+\newwrite\liftarm at animatewritetimeline
+\newcounter{liftarm at animatenumberofanimation}
+\newcommand{\liftarmanimate}[4][]{%
+\liftarm at animatetrue%
+\addtocounter{liftarm at animatenumberofanimation}{1}%
+\setcounter{liftarm at animatenumberofsteps}{-1}%
+\gdef\liftarm at animateframes{}%
+\gdef\liftarm at animateframestrace{}%
+\setcounter{liftarm at animatestepnumber}{-1}%
+\foreach\liftarm at n in {#3}{%
+\addtocounter{liftarm at animatenumberofsteps}{1}%
+\gappto\liftarm at animateframes{\newframe\addtocounter{liftarm at animatestepnumber}{1}#4}%
+\xappto\liftarm at animateframes{{\liftarm at n}}%
+}%
+\patchcmd{\liftarm at animateframes}{\newframe}{}{}{}%
+\csgdef{liftarm at animatetimeline0}{c,}%
+\foreach\liftarm at n in {1,...,\theliftarm at animatenumberofsteps}{%
+\csgdef{liftarm at animatetimeline\liftarm at n}{}%
+}%
+\setcounter{liftarm at animateframenumber}{\theliftarm at animatenumberofsteps}%
+\IfFileExists{\jobname\theliftarm at animatenumberofanimation.tln}{}{%
+\immediate\openout\liftarm at animatewritetimeline=\jobname\theliftarm at animatenumberofanimation.tln%
+\immediate\write\liftarm at animatewritetimeline{::c,0}%
+\immediate\closeout\liftarm at animatewritetimeline%
+}%
+\begin{animateinline}[#1,timeline=\jobname\theliftarm at animatenumberofanimation.tln]{#2}%
+\liftarm at animateframes%
+\liftarm at animateframestrace%
+\end{animateinline}%
+\immediate\openout\liftarm at animatewritetimeline=\jobname\theliftarm at animatenumberofanimation.tln%
+\foreach\liftarm at n in {0,...,\theliftarm at animatenumberofsteps}{%
+\immediate\write\liftarm at animatewritetimeline{::\csname liftarm at animatetimeline\liftarm at n\endcsname\liftarm at n}%
+}%
+\immediate\closeout\liftarm at animatewritetimeline%
+\liftarm at animatefalse%
+}
 \endinput
\ No newline at end of file



More information about the tex-live-commits mailing list.