summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-09-03 22:56:48 +0000
committerKarl Berry <karl@freefriends.org>2012-09-03 22:56:48 +0000
commit49ee169240901a3f97d82ab2e35e37cf237b3961 (patch)
tree75a8e3f59aebd5cac9c9132f0bdbd606052cde67 /Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex
parent8028e80de243e75b6cd0bdc9aec5dbed7c6be192 (diff)
new tikz package hobby (3sep12)
git-svn-id: svn://tug.org/texlive/trunk@27584 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex')
-rw-r--r--Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex289
1 files changed, 289 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex b/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex
new file mode 100644
index 00000000000..9214dfd6dd3
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex
@@ -0,0 +1,289 @@
+%%
+%% This is file `tikzlibraryhobby.code.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% hobby.dtx (with options: `tikzlibrary')
+%% ----------------------------------------------------------------
+%% hobby --- a TikZ/PGF library for drawing smooth(ish) curves using
+%% Hobby's algorithm (implemented in LaTeX3)
+%% E-mail: stacey@math.ntnu.no
+%% Released under the LaTeX Project Public License v1.3c or later
+%% See http://www.latex-project.org/lppl.txt
+%% ----------------------------------------------------------------
+%%
+\usepgflibrary{hobby}
+\let\hobby@opts=\pgfutil@empty
+\tikzset{
+ curve through/.style={
+ to path={
+ \pgfextra{
+ \expandafter\curvethrough\expandafter[\hobby@opts]{%
+ (\tikztostart) .. #1 .. (\tikztotarget)%
+ }
+ }
+ }
+ },
+ tension in/.code = {},
+ tension out/.code = {},
+ tension/.code = {},
+ excess angle/.code = {},
+ closed/.code = {%
+ \expandafter\def\expandafter\hobby@opts\expandafter{\hobby@opts%
+ closed=#1,disjoint=#1}%
+ },
+ closed/.default = true,
+ in angle/.code = {%
+ \pgfmathparse{#1*pi/180}%
+ \edef\@temp{ in angle=\pgfmathresult,}%
+ \expandafter\expandafter\expandafter%
+ \def%
+ \expandafter\expandafter\expandafter%
+ \hobby@opts%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\hobby@opts\@temp}%
+ },
+ out angle/.code = {%
+ \pgfmathparse{#1*pi/180}%
+ \edef\@temp{ out angle=\pgfmathresult,}%
+ \expandafter\expandafter\expandafter%
+ \def%
+ \expandafter\expandafter\expandafter%
+ \hobby@opts%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\hobby@opts\@temp}%
+ },
+ in curl/.code = {%
+ \expandafter\def\expandafter\hobby@opts\expandafter{\hobby@opts in curl=#1,}%
+ },
+ out curl/.code = {%
+ \expandafter\def\expandafter\hobby@opts\expandafter{\hobby@opts out curl=#1,}%
+ },
+ use Hobby shortcut/.code={%
+ \let\tikz@curveto@auto=\hobby@curveto@auto
+ }
+}
+\newcommand\curvethrough[2][]{%
+ \hobbyinit\hobby@moveto\hobby@curveto\hobby@close
+ \hobbysetparams{#1}%
+ \hobby@processpts{#2}%
+}
+\newcommand\hobby@processpts[1]{%
+ \pgfutil@in@{..}{#1}%
+ \ifpgfutil@in@%
+ \hobby@getonepoint #1 \relax
+ \let\hobby@next=\hobby@processpts
+ \else
+ \def\hobby@pt{#1}%
+ \def\hobby@rest{}%
+ \let\hobby@next=\hobbygenpath
+ \fi
+ \let\tikz@scan@point@options=\pgfutil@empty
+ \expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\hobby@pt\relax
+ \pgfmathsetmacro\hobby@x{\the\pgf@x/1cm}%
+ \pgfmathsetmacro\hobby@y{\the\pgf@y/1cm}%
+ \expandafter\hobbyaddpoint\expandafter{\tikz@scan@point@options,%
+ x = \hobby@x, y = \hobby@y}%
+ \expandafter\hobby@next\expandafter{\hobby@rest}%
+}
+\def\hobby@getonepoint#1..#2\relax{%
+ \def\hobby@pt{#1}%
+ \def\hobby@rest{#2}%
+}
+\def\hobby@curveto@auto{%
+ \hobbyinit\pgfutil@gobble\hobby@curveto\hobby@close
+ \pgfmathsetmacro\hobby@x{\the\tikz@lastx/1cm}%
+ \pgfmathsetmacro\hobby@y{\the\tikz@lasty/1cm}%
+ \pgfutil@ifundefined{tikz@scan@point@options}{%
+ \hobbyaddpoint{x = \hobby@x, y = \hobby@y}%
+ }{%
+ \expandafter\hobbyaddpoint\expandafter{\tikz@scan@point@options,%
+ x = \hobby@x, y = \hobby@y}%
+ }%
+ \let\tikz@scan@point@options=\pgfutil@empty
+ \tikz@scan@one@point\hobby@addfromtikz}
+\def\hobby@addfromtikz#1{%
+ #1%
+ \tikz@make@last@position{#1}%
+ \pgfmathsetmacro\hobby@x{\the\pgf@x/1cm}%
+ \pgfmathsetmacro\hobby@y{\the\pgf@y/1cm}%
+ \expandafter\hobbyaddpoint\expandafter{\tikz@scan@point@options,%
+ x = \hobby@x, y = \hobby@y}%
+ \hobby@donext}
+\def\hobby@donext{%
+ \pgfutil@ifnextchar.%
+ {\hobby@curveto@check}%
+ {\hobby@finish@auto}}%
+\def\hobby@curveto@check..{%
+ \pgfutil@ifnextchar c%
+ {\hobby@maybefinish@auto}%
+ {\hobby@curveto@continue}}%
+\def\hobby@maybefinish@auto c{%
+ \pgfutil@ifnextchar o%
+ {\hobby@finish@auto .. c}%
+ {\hobby@closeandfinish@auto}}
+\def\hobby@closeandfinish@auto ycle{%
+ \hobbysetparams{closed=true,disjoint=true}%
+ \hobby@finish@auto%
+}
+\def\hobby@curveto@continue{%
+ \let\tikz@scan@point@options=\pgfutil@empty
+ \tikz@scan@one@point\hobby@addfromtikz}
+\def\hobby@finish@auto{%
+ \hobbygenpath
+ \tikz@scan@next@command%
+}
+\tikzset{
+ quick curve through/.style={%
+ to path={%
+ \pgfextra{%
+ \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)%
+ \edef\hobby@qpoints{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \def\hobby@qpointa{}%
+ \def\hobby@quick@path{}%
+ \def\hobby@angle{}%
+ \tikz@scan@one@point\hobby@quickfirst #1 (\tikztotarget)\relax
+ }
+ \hobby@quick@path
+ }
+ }
+}
+\pgfmathsetmacro\hobby@sf{10cm}
+\def\hobby@quickfirst#1{%
+ #1%
+ \edef\hobby@qpointa{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfutil@ifnextchar\relax{%
+ \edef\hobby@quick@path{ -- (\the\pgf@x,\the\pgf@y)}%
+ }{%
+ \tikz@scan@one@point\hobby@quick}}
+\def\hobby@quick#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
+ \pgfmathsetmacro\hobby@alpha{%
+ sqrt(2) * (sin(\hobby@thetazero r) - 1/16 * sin(\hobby@phione r))%
+* (sin(\hobby@phione r) - 1/16 * sin(\hobby@thetazero r))%
+ * (cos(\hobby@thetazero r) - cos(\hobby@phione r))}%
+ \pgfmathsetmacro\hobby@rho{%
+ (2 + \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)%
+ * cos(\hobby@thetazero r) + (3 - sqrt(5))/2 * cos(\hobby@phione r))}%
+ \pgfmathsetmacro\hobby@sigma{%
+ (2 - \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)%
+ * cos(\hobby@phione r) + (3 - sqrt(5))/2 * cos(\hobby@thetazero r))}%
+ \hobby@qpoints
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgfmathsetlength\pgf@xa{%
+ \pgf@xa + \hobby@dzero * \hobby@rho%
+ * cos((\hobby@thetazero + \hobby@omegazero) r)/3*\hobby@sf}%
+ \pgfmathsetlength\pgf@ya{%
+ \pgf@ya + \hobby@dzero * \hobby@rho%
+ * sin((\hobby@thetazero + \hobby@omegazero) r)/3*\hobby@sf}%
+ \hobby@qpointa
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ \pgfmathsetlength\pgf@xb{%
+ \pgf@xb - \hobby@dzero * \hobby@sigma%
+ * cos((-\hobby@phione + \hobby@omegazero) r)/3*\hobby@sf}%
+ \pgfmathsetlength\pgf@yb{%
+ \pgf@yb - \hobby@dzero * \hobby@sigma%
+ * sin((-\hobby@phione + \hobby@omegazero) r)/3*\hobby@sf}%
+ \hobby@qpointa
+ \edef\hobby@quick@path{\hobby@quick@path .. controls%
+ (\the\pgf@xa,\the\pgf@ya) and (\the\pgf@xb,\the\pgf@yb) .. (\the\pgf@x,\the\pgf@y) }%
+ \let\hobby@qpoints=\hobby@qpointa
+ #1
+ \edef\hobby@qpointa{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfutil@ifnextchar\relax{%
+ \pgfmathsetmacro\hobby@alpha{%
+ sqrt(2) * (sin(\hobby@thetaone r) - 1/16 * sin(\hobby@phitwo r))%
+ * (sin(\hobby@phitwo r) - 1/16 * sin(\hobby@thetaone r))%
+ * (cos(\hobby@thetaone r) - cos(\hobby@phitwo r))}%
+ \pgfmathsetmacro\hobby@rho{%
+ (2 + \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)%
+ * cos(\hobby@thetaone r) + (3 - sqrt(5))/2 * cos(\hobby@phitwo r))}%
+ \pgfmathsetmacro\hobby@sigma{%
+ (2 - \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)%
+ * cos(\hobby@phitwo r) + (3 - sqrt(5))/2 * cos(\hobby@thetaone r))}%
+ \hobby@qpoints
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgfmathsetlength\pgf@xa{%
+ \pgf@xa + \hobby@done * \hobby@rho%
+ * cos((\hobby@thetaone + \hobby@omegaone) r)/3*\hobby@sf}%
+ \pgfmathsetlength\pgf@ya{%
+ \pgf@ya + \hobby@done * \hobby@rho%
+ * sin((\hobby@thetaone + \hobby@omegaone) r)/3*\hobby@sf}%
+ \hobby@qpointa
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ \pgfmathsetlength\pgf@xb{%
+ \pgf@xb - \hobby@done * \hobby@sigma%
+ * cos((-\hobby@phitwo + \hobby@omegaone) r)/3*\hobby@sf}%
+ \pgfmathsetlength\pgf@yb{%
+ \pgf@yb - \hobby@done * \hobby@sigma%
+ * sin((-\hobby@phitwo + \hobby@omegaone) r)/3*\hobby@sf}%
+ \hobby@qpointa
+ \edef\hobby@quick@path{\hobby@quick@path .. controls%
+ (\the\pgf@xa,\the\pgf@ya) and (\the\pgf@xb,\the\pgf@yb) .. (\the\pgf@x,\the\pgf@y) }%
+}{%
+\tikz@scan@one@point\hobby@quick}}
+%%
+%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no>
+%%
+%% This file 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 is "maintained" (as per LPPL maintenance status) by
+%% Andrew Stacey.
+%%
+%% This work consists of the files hobby.dtx
+%% hobby_doc.tex
+%% and the derived files hobby.code.tex
+%% pgflibraryhobby.code.tex
+%% tikzlibraryhobby.code.tex
+%% hobby.ins
+%% hobby.pdf
+%% hobby_doc.pdf
+%% README.txt
+%%
+%%
+%% End of file `tikzlibraryhobby.code.tex'.