summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-13 22:56:07 +0000
committerKarl Berry <karl@freefriends.org>2013-04-13 22:56:07 +0000
commit658facdfe16a2d2b43c7312b9b15bebbf3c89d8e (patch)
tree6b219a6bd62fa7eda6d3aa87fccf509cc3fc7191 /Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex
parent5ffaf0fed7a947071a4ad491d01164a10e97b7ed (diff)
hobby (13apr13)
git-svn-id: svn://tug.org/texlive/trunk@29895 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex')
-rw-r--r--Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex179
1 files changed, 178 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex b/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex
index 3e4e609dae9..5d0f4a91996 100644
--- a/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex
+++ b/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex
@@ -18,7 +18,7 @@
/pgf/hobby/.is family,
/pgf/hobby/.cd,
x/.code={\pgf@x=#1cm},
- y/.code={\pgf@y=#1cm},
+ y/.code={\pgf@y=#1cm}
}
\def\hobby@curveto#1#2#3{%
\pgfpathcurveto{\hobby@topgf{#1}}{\hobby@topgf{#2}}{\hobby@topgf{#3}}%
@@ -32,6 +32,183 @@
\def\hobby@close#1{%
\pgfpathclose
}
+\def\pgfplothandlerhobby{%
+ \def\pgf@plotstreamstart{%
+ \hobbyinit\hobby@moveto\hobby@curveto\hobby@close
+ \global\let\pgf@plotstreampoint=\pgf@plot@hobby@firstpt
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble
+ \gdef\pgf@plotstreamend{%
+ \ifhobby@externalise
+ \ifx\hobby@path@name\pgfutil@empty
+ \hobbygenusepath
+ \else
+ \hobbygenuseifnecpath{\hobby@path@name}%
+ \fi
+ \else
+ \hobbygenusepath
+ \fi
+ \ifx\hobby@path@name\pgfutil@empty
+ \else
+ \hobbysavepath{\hobby@path@name}%
+ \fi
+ \global\let\hobby@path@name=\pgfutil@empty
+ }%
+ \let\tikz@scan@point@options=\pgfutil@empty
+ }
+}
+\def\pgfplothandlerclosedhobby{%
+ \def\pgf@plotstreamstart{%
+ \hobbyinit\hobby@moveto\hobby@curveto\hobby@close
+ \hobbysetparams{closed=true,disjoint=true}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@hobby@firstpt
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble
+ \gdef\pgf@plotstreamend{%
+ \ifhobby@externalise
+ \ifx\hobby@path@name\pgfutil@empty
+ \hobbygenusepath
+ \else
+ \hobbygenuseifnecpath{\hobby@path@name}%
+ \fi
+ \else
+ \hobbygenusepath
+ \fi
+ \ifx\hobby@path@name\pgfutil@empty
+ \else
+ \hobbysavepath{\hobby@path@name}%
+ \fi
+ \global\let\hobby@path@name=\pgfutil@empty
+ }%
+ }
+}
+\def\pgf@plot@hobby@firstpt#1{%
+ \pgf@plot@first@action{#1}%
+ \pgf@plot@hobby@handler{#1}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@hobby@handler
+}
+\def\pgf@plot@hobby@handler#1{%
+ #1%
+ \pgfmathsetmacro\hobby@x{\the\pgf@x/1cm}%
+ \pgfmathsetmacro\hobby@y{\the\pgf@y/1cm}%
+ \hobbyaddpoint{x = \hobby@x, y = \hobby@y}%
+ }
+\def\pgfplothandlerquickhobby{%
+ \def\pgf@plotstreamstart{%
+ \global\let\hobby@quick@curveto=\pgfpathcurveto
+ \global\let\pgf@plotstreampoint=\pgf@plot@qhobby@firstpt
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble
+ \global\let\pgf@plotstreamend=\pgf@plot@qhobby@end
+ }
+}
+\def\pgf@plot@qhobby@firstpt#1{%
+ #1%
+ \edef\hobby@temp{\noexpand\pgf@plot@first@action{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}\hobby@temp%
+ \xdef\hobby@qpoints{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \gdef\hobby@qpointa{}%
+ \gdef\hobby@angle{}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@qhobby@secondpt
+}
+\def\pgf@plot@qhobby@secondpt#1{%
+ #1%
+ \xdef\hobby@qpointa{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@qhobby@handler
+}
+\def\pgf@plot@qhobby@handler#1{%
+ #1
+ \edef\hobby@temp{\noexpand\hobby@quick@compute{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}\hobby@temp
+ \global\let\hobby@qpointa=\hobby@qpointa
+ \global\let\hobby@qpoints=\hobby@qpoints
+ \global\let\hobby@angle=\hobby@angle
+ \global\let\hobby@thetaone=\hobby@thetaone
+ \global\let\hobby@phitwo=\hobby@phitwo
+ \global\let\hobby@done=\hobby@done
+ \global\let\hobby@omegaone=\hobby@omegaone
+}
+\def\pgf@plot@qhobby@end{%
+ \hobby@quick@computeend
+}
+\pgfmathsetmacro\hobby@sf{10cm}
+\def\hobby@quick@compute#1{%
+ #1%
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ \hobby@qpointa
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \advance\pgf@xb by -\pgf@xa
+ \advance\pgf@yb by -\pgf@ya
+ \pgfmathsetmacro\hobby@done{sqrt((\pgf@xb/\hobby@sf)^2 + (\pgf@yb/\hobby@sf)^2)}%
+ \pgfmathsetmacro\hobby@omegaone{rad(atan2(\pgf@xb,\pgf@yb))}%
+ \hobby@qpoints
+ \advance\pgf@xa by -\pgf@x
+ \advance\pgf@ya by -\pgf@y
+ \pgfmathsetmacro\hobby@dzero{sqrt((\pgf@xa/\hobby@sf)^2 + (\pgf@ya/\hobby@sf)^2)}%
+ \pgfmathsetmacro\hobby@omegazero{rad(atan2(\pgf@xa,\pgf@ya))}%
+ \pgfmathsetmacro\hobby@psi{\hobby@omegaone - \hobby@omegazero}%
+ \pgfmathsetmacro\hobby@psi{\hobby@psi > pi ? \hobby@psi - 2*pi : \hobby@psi}%
+ \pgfmathsetmacro\hobby@psi{\hobby@psi < -pi ? \hobby@psi + 2*pi : \hobby@psi}%
+ \ifx\hobby@angle\pgfutil@empty
+ \pgfmathsetmacro\hobby@thetaone{-\hobby@psi * \hobby@done%
+/(\hobby@done + \hobby@dzero)}%
+ \pgfmathsetmacro\hobby@thetazero{-\hobby@psi - \hobby@thetaone}%
+ \let\hobby@phione=\hobby@thetazero
+ \let\hobby@phitwo=\hobby@thetaone
+ \else
+ \let\hobby@thetazero=\hobby@angle
+ \pgfmathsetmacro\hobby@thetaone{%
+ -(2 * \hobby@psi + \hobby@thetazero) * \hobby@done%
+ / (2 * \hobby@done + \hobby@dzero)}%
+ \pgfmathsetmacro\hobby@phione{-\hobby@psi - \hobby@thetaone}%
+ \let\hobby@phitwo=\hobby@thetaone
+ \fi
+ \let\hobby@angle=\hobby@thetaone
+ \hobby@quick@ctrlpts{\hobby@thetazero}{\hobby@phione}{\hobby@qpoints}{\hobby@qpointa}{\hobby@dzero}{\hobby@omegazero}%
+ \edef\hobby@temp{\noexpand\hobby@quick@curveto{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+\hobby@temp
+ \global\let\hobby@qpoints=\hobby@qpointa
+ #1
+ \xdef\hobby@qpointa{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \global\let\hobby@angle=\hobby@angle
+ \global\let\hobby@phitwo=\hobby@phitwo
+ \global\let\hobby@thetaone=\hobby@thetaone
+\global\let\hobby@done=\hobby@done
+\global\let\hobby@omegaone=\hobby@omegaone
+}
+\def\hobby@quick@computeend{%
+ \hobby@quick@ctrlpts{\hobby@thetaone}{\hobby@phitwo}{\hobby@qpoints}{\hobby@qpointa}{\hobby@done}{\hobby@omegaone}%
+ \edef\hobby@temp{\noexpand\hobby@quick@curveto{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+\hobby@temp
+}%
+\def\hobby@quick@ctrlpts#1#2#3#4#5#6{%
+ \pgfmathsetmacro\hobby@alpha{%
+ sqrt(2) * (sin(#1 r) - 1/16 * sin(#2 r))%
+* (sin(#2 r) - 1/16 * sin(#1 r))%
+ * (cos(#1 r) - cos(#2 r))}%
+ \pgfmathsetmacro\hobby@rho{%
+ (2 + \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)%
+ * cos(#1 r) + (3 - sqrt(5))/2 * cos(#2 r))}%
+ \pgfmathsetmacro\hobby@sigma{%
+ (2 - \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)%
+ * cos(#2 r) + (3 - sqrt(5))/2 * cos(#1 r))}%
+ #3%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgfmathsetlength\pgf@xa{%
+ \pgf@xa + #5 * \hobby@rho%
+ * cos((#1 + #6) r)/3*\hobby@sf}%
+ \pgfmathsetlength\pgf@ya{%
+ \pgf@ya + #5 * \hobby@rho%
+ * sin((#1 + #6) r)/3*\hobby@sf}%
+ #4%
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ \pgfmathsetlength\pgf@xb{%
+ \pgf@xb - #5 * \hobby@sigma%
+ * cos((-#2 + #6) r)/3*\hobby@sf}%
+ \pgfmathsetlength\pgf@yb{%
+ \pgf@yb - #5 * \hobby@sigma%
+ * sin((-#2 + #6) r)/3*\hobby@sf}%
+ #4%
+}
%%
%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no>
%%