~tex-sx/tex-sx/development

« back to all changes in this revision

Viewing changes to hobby_test.tex

  • Committer: Andrew Stacey
  • Date: 2012-11-27 10:14:33 UTC
  • mto: This revision was merged to the branch mainline in revision 158.
  • Revision ID: stacey@math.ntnu.no-20121127101433-km21h0z5g6hgjnds
Subnode command added to tikzmark, some tweaks in option processing for hobby (not stable yet)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
\immediate\write18{tex hobby.dtx}
2
2
\documentclass{article}
 
3
\usepackage{pgfplots}
 
4
\usetikzlibrary{hobby}
 
5
 
 
6
\newif\ifhobbyinpath
 
7
\tikzset{
 
8
  tangent/.style={%
 
9
    called={tangent #1},
 
10
    in angle={(180+#1)},
 
11
    Hobby finish,
 
12
    Hobby action={\message{breaking path}},
 
13
    designated Hobby path=next,
 
14
    out angle=#1,
 
15
  },
 
16
  called/.code={\message{#1 got called}},
 
17
  every path/.append style={clear next Hobby path options,clear this Hobby path options},
 
18
}
 
19
 
 
20
 
 
21
\begin{document}
 
22
 
 
23
 
 
24
\begin{tikzpicture}[use Hobby shortcut]
 
25
\draw[help lines] (-5,-5) grid (5,5);
 
26
\draw (-5,0) -- (5,0) (0,-5) -- (0,5);
 
27
\draw[thick] ([tangent=150]-5,2) .. ([tangent=0]-3,3) .. (-1,1) .. (0,-1.3) .. ([tangent=0]1,-2) .. ([tangent=45]2,-1.5) .. ([tangent=0]3,-2) .. ([tangent=-45]5,-4);
 
28
\end{tikzpicture}
 
29
 
 
30
\begin{tikzpicture}[use Hobby shortcut]
 
31
\draw[help lines] (-5,-5) grid (5,5);
 
32
\draw (-5,0) -- (5,0) (0,-5) -- (0,5);
 
33
\draw[thick] (-5,2) .. ([tangent=0]-3,3) .. (-1,1) .. (0,-1.3) .. %
 
34
([tangent=0]1,-2) .. ([tangent=45]2,-1.5) .. ([tangent=0]3,-2) .. (5,-4);
 
35
\end{tikzpicture}
 
36
 
 
37
\begin{tikzpicture}[use Hobby shortcut]
 
38
\draw[help lines] (-5,-5) grid (5,5);
 
39
\draw (-5,0) -- (5,0) (0,-5) -- (0,5);
 
40
\draw[thick] (-5,2) .. (-3,3) .. (-1,1) .. (0,-1.3) .. %
 
41
([tangent=0]1,-2) .. ([tangent=45]2,-1.5) .. (3,-2) .. (5,-4);
 
42
\end{tikzpicture}
 
43
\end{document}
 
44
 
 
45
\begin{tikzpicture}
 
46
\draw[use Hobby shortcut] (0,0) .. ([tangent=45]1,1) .. (2,0) .. (3,1) .. (4,0);
 
47
\end{tikzpicture}
 
48
\end{document}
 
49
 
 
50
\begin{tikzpicture}
 
51
\draw[line width=3mm,red,use Hobby shortcut,save Hobby path={saved}] (0,0) .. ([blank=soft]1,1) .. (2,0);
 
52
\draw[ultra thick,yellow,restore and use Hobby path={saved}{disjoint,invert soft blanks}];
 
53
\end{tikzpicture}
 
54
 
 
55
\begin{tikzpicture}
 
56
\draw[blue,save Hobby path={left}] ([out angle=90,in angle=-90]1,0) .. (1,1) .. ([blank=soft]0,2) .. (1,3) .. (1,4);
 
57
\draw[show Hobby path={left},red] ([out angle=90,in angle=-90]0,0) .. (0,1) .. (1,2) .. (0,3) .. (0,4);
 
58
\tikzset{show Hobby path={left}}
 
59
\draw[blue,show Hobby path={left},restore and use Hobby path={left}{disjoint,invert soft blanks}];
 
60
\end{tikzpicture}
 
61
\end{document}
 
62
 
 
63
\begin{document}
 
64
\begin{tikzpicture}
 
65
\begin{axis}
 
66
\addplot +[smooth] {rnd};
 
67
\addplot +[hobby] {rnd};
 
68
\end{axis}
 
69
\end{tikzpicture}
 
70
\end{document}
 
71
 
 
72
\documentclass{article}
3
73
\usepackage{amsmath}
4
74
\usepackage{tikz}
5
75
\usetikzlibrary{hobby}
6
76
 
7
77
\usepackage[silent]{trace-pgfkeys}
8
78
 
9
 
\tikzset{use quick Hobby shortcut}
 
79
%\tikzset{use quick Hobby shortcut}
10
80
 
11
81
\begin{document}
12
82
 
 
83
\begin{tikzpicture}
 
84
\draw[use Hobby shortcut] (0,0) .. (1,1) .. (2,1);
 
85
\end{tikzpicture}
 
86
\end{document}
 
87
 
 
88
\tikz[smooth] \draw plot coordinates {(0,0) (1,1) (2,0) (3,1) (2,1) (10:2cm)};
 
89
 
 
90
\tikz[hobby] \draw plot coordinates {(0,0) (1,1) (2,0) (3,1) (2,1) (10:2cm)};
 
91
 
 
92
\tikz[closed hobby] \draw plot coordinates {(0,0) (1,1) (2,0) (3,1) (2,1) (10:2cm)};
 
93
 
 
94
\tikz[quick hobby] \draw plot coordinates {(0,0) (1,1) (2,0) (3,1) (2,1) (10:2cm)};
 
95
\end{document}
 
96
 
13
97
\begin{tikzpicture}[use Hobby shortcut]
14
98
\draw ([out angle=10]0,0) .. ([in angle=90]1,1);
15
99
\end{tikzpicture}