Guest User

Untitled

a guest
Mar 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. documentclass[tikz,border=10pt,multi]{standalone}
  2.  
  3. begin{document}
  4.  
  5. begin{tikzpicture}
  6.  
  7. draw (0,0) .. controls (1,1) and (2,-1) .. (3,0);
  8.  
  9. end{tikzpicture}
  10.  
  11. end{document}
  12.  
  13. draw (0,0) .. controls (??,??) and (??,??) .. (3,0);
  14.  
  15. documentclass[parskip=full]{scrartcl}
  16. usepackage[margin=2cm,paperheight=40cm]{geometry}
  17. usepackage{tikz}
  18.  
  19. newcommandDrawControl[3]{
  20. node[#2,circle,fill=#2,inner sep=2pt,label={above:$#1$},label={[black]below:{footnotesize#3}}] at #1 {}
  21. }
  22.  
  23. pagestyle{empty}
  24.  
  25. begin{document}
  26. centering
  27.  
  28. One control point:\
  29. begin{tikzpicture}[baseline]
  30. draw[help lines] (0,0) grid (8,5);
  31. draw[ultra thick]
  32. (1,0)
  33. .. controls (4,0) ..
  34. (7,0) DrawControl{(4,0)}{black}{};
  35. draw[ultra thick,blue]
  36. (1,0)
  37. .. controls (4,2) ..
  38. (7,0) DrawControl{(4,2)}{blue}{};
  39. draw[ultra thick,red]
  40. (1,0)
  41. .. controls (4,6) ..
  42. (7,0) DrawControl{(4,6)}{red}{};
  43. end{tikzpicture}hfill
  44. begin{tikzpicture}[baseline]
  45. draw[help lines] (0,0) grid (8,5);
  46. draw[ultra thick]
  47. (1,0)
  48. .. controls (2,0) ..
  49. (7,0) DrawControl{(2,0)}{black}{};
  50. draw[ultra thick,blue]
  51. (1,0)
  52. .. controls (2,2) ..
  53. (7,0) DrawControl{(2,2)}{blue}{};
  54. draw[ultra thick,red]
  55. (1,0)
  56. .. controls (2,6) ..
  57. (7,0) DrawControl{(2,6)}{red}{};
  58. end{tikzpicture}
  59.  
  60. rule{textwidth}{2pt}
  61.  
  62. Two control points:\
  63. begin{tikzpicture}[baseline]
  64. draw[help lines] (0,0) grid (8,3);
  65. draw[ultra thick,blue]
  66. (1,0)
  67. .. controls (3,2) and (5,2) ..
  68. (7,0) DrawControl{(3,2)}{blue}{1}DrawControl{(5,2)}{blue}{2} ;
  69. draw[ultra thick,red]
  70. (1,0)
  71. .. controls (3,4) and (5,4) ..
  72. (7,0) DrawControl{(3,4)}{red}{1}DrawControl{(5,4)}{red}{2};
  73. end{tikzpicture}hfill
  74. begin{tikzpicture}[baseline]
  75. draw[help lines] (0,0) grid (8,3);
  76. draw[ultra thick,blue]
  77. (1,0)
  78. .. controls (2,2) and (6,2) ..
  79. (7,0) DrawControl{(2,2)}{blue}{1}DrawControl{(6,2)}{blue}{2};
  80. draw[ultra thick,red]
  81. (1,0)
  82. .. controls (2,4) and (6,4) ..
  83. (7,0) DrawControl{(2,4)}{red}{1}DrawControl{(6,4)}{red}{2};
  84. end{tikzpicture}
  85.  
  86. rule{textwidth}{2pt}
  87.  
  88. vspace{3cm}
  89.  
  90. begin{tikzpicture}[baseline]
  91. draw[help lines] (0,0) grid (8,3);
  92. draw[overlay,ultra thick,blue]
  93. (1,0)
  94. .. controls (10,2) and (-2,2) ..
  95. (7,0) DrawControl{(10,2)}{blue}{1}DrawControl{(-2,2)}{blue}{2};
  96. draw[overlay,ultra thick,red]
  97. (1,0)
  98. .. controls (12,4) and (-4,4) ..
  99. (7,0) DrawControl{(12,4)}{red}{1}DrawControl{(-4,4)}{red}{2};
  100. end{tikzpicture}
  101.  
  102. rule{textwidth}{2pt}
  103.  
  104. begin{tikzpicture}[baseline]
  105. draw[help lines] (0,-2) grid (8,2);
  106. draw[ultra thick,blue]
  107. (1,0)
  108. .. controls (3,2) and (5,-2) ..
  109. (7,0) DrawControl{(3,2)}{blue}{1}DrawControl{(5,-2)}{blue}{2};
  110. draw[ultra thick,red]
  111. (1,0)
  112. .. controls (-1,5) and (8,-5) ..
  113. (7,0) DrawControl{(-1,5)}{red}{1}DrawControl{(8,-5)}{red}{2};
  114. end{tikzpicture}
  115.  
  116. rule{textwidth}{2pt}
  117.  
  118. end{document}
  119.  
  120. draw (0,0) .. controls (??,??) and (??,??) .. (3,0);
  121.  
  122. draw (0,0) .. controls (1,2) and (2,-2) .. (3,0);
  123.  
  124. tikz-bezier-animation.tex
  125.  
  126. documentclass[tikz]{standalone}
  127.  
  128. usetikzlibrary{decorations.pathreplacing,backgrounds}
  129.  
  130. tikzset{
  131. show curve controls/.style={
  132. decoration={
  133. show path construction,
  134. curveto code={
  135. draw[#1!50]
  136. (tikzinputsegmentfirst)
  137. -- (tikzinputsegmentsupporta)
  138. -- (tikzinputsegmentsupportb)
  139. -- (tikzinputsegmentlast)
  140. ;
  141. fill[#1!50] (tikzinputsegmentsupporta) circle(1pt);
  142. fill[#1!50] (tikzinputsegmentsupportb) circle(1pt);
  143. draw[#1,line width=1pt]
  144. (tikzinputsegmentfirst)
  145. .. controls (tikzinputsegmentsupporta)
  146. and (tikzinputsegmentsupportb) ..
  147. (tikzinputsegmentlast);
  148. }
  149. },decorate
  150. }
  151. }
  152.  
  153. begin{document}
  154. foreach p in {0,10,...,360} {
  155. begin{tikzpicture}
  156. begin{scope}
  157. path (-4,-2) rectangle (4,2.1);
  158. coordinate (a) at (-2,0);
  159. coordinate (b) at (2,0);
  160. path (a) ++(1,0) ++(p:0 and 2) coordinate (a1);
  161. path (b) ++(-1,0) ++({180-p}:0 and 2) coordinate (b1);
  162. draw[show curve controls={red}] (a) .. controls (a1) and (b1) .. (b);
  163. end{scope}
  164. begin{scope}[yshift=-4.5cm]
  165. path (-4,-1) rectangle (4,4);
  166. coordinate (a) at (-2,0);
  167. coordinate (b) at (2,0);
  168. path (a) ++(45:3) ++(p:3 and 0) coordinate (a1);
  169. path (b) ++(90+45:3) ++(180-p:3 and 0) coordinate (b1);
  170. draw[show curve controls={blue}] (a) .. controls (a1) and (b1) .. (b);
  171. end{scope}
  172. begin{scope}[yshift=-6cm]
  173. path (-4,-3) rectangle (4,4);
  174. coordinate (a) at (-2,0);
  175. coordinate (b) at (2,0);
  176. path (a) ++(1,0) [rotate=45] ++(p:0 and 2) coordinate (a1);
  177. path (b) ++(-1,0) [rotate=45] ++({180+p}:0 and 2) coordinate (b1);
  178. draw[show curve controls={green!50!black}]
  179. (a) .. controls (a1) and (b1) .. (b);
  180. end{scope}
  181. begin{pgfonlayer}{background}
  182. fill[white] (current bounding box.south west)
  183. rectangle (current bounding box.north east);
  184. end{pgfonlayer}
  185. end{tikzpicture}
  186. }
  187. end{document}
  188.  
  189. documentclass[tikz,border=5]{standalone}
  190. usetikzlibrary{decorations.pathreplacing}
  191. tikzset{%
  192. show curve controls/.style={
  193. postaction={
  194. decoration={
  195. show path construction,
  196. curveto code={
  197. draw [blue]
  198. (tikzinputsegmentfirst) -- (tikzinputsegmentsupporta)
  199. (tikzinputsegmentlast) -- (tikzinputsegmentsupportb);
  200. fill [red, opacity=0.5]
  201. (tikzinputsegmentsupporta) circle [radius=.5ex]
  202. (tikzinputsegmentsupportb) circle [radius=.5ex];
  203. }
  204. },
  205. decorate
  206. }}}
  207. begin{document}
  208. begin{tikzpicture}
  209. draw [help lines] (-4, -1) grid (4, 5);
  210. draw [show curve controls]
  211. (-3, 4) .. controls ++(135:-1) and ++(135:1) .. (0, 4);
  212. draw [show curve controls] (0, 0)
  213. .. controls ++(165:-1) and ++(240: 1) .. ( 3, 2)
  214. .. controls ++(240:-1) and ++(165:-1) .. ( 2, 4)
  215. .. controls ++(165: 1) and ++(175:-2) .. (-1, 2)
  216. .. controls ++(175: 2) and ++(165: 1) .. ( 0, 0);
  217. end{tikzpicture}
  218. end{document}
  219.  
  220. documentclass[border=5pt,tikz]{standalone}
  221. tikzset{
  222. ctrlpoint/.style={%
  223. draw=gray,
  224. circle,
  225. inner sep=0,
  226. minimum width=1ex,
  227. }
  228. }
  229. newcommandBezier[4]{% bezier (lowercase 'b') was already defined elsewhere
  230. node (p1) [ctrlpoint,label=90:$P_1$] at (#1) {};
  231. node (p2) [ctrlpoint,label=90:$P_2$] at (#2) {};
  232. node (p3) [ctrlpoint,label=90:$P_3$] at (#3) {};
  233. node (p4) [ctrlpoint,label=90:$P_4$] at (#4) {};
  234. draw [gray] (p1) -- (p2) -- (p3) -- (p4);
  235. draw [blue] (#1) .. controls (#2) and (#3) .. (#4);
  236. }
  237. begin{document}
  238. begin{tikzpicture}
  239. Bezier{0,0}{1,1}{2,-1}{3,0}
  240. begin{scope}[xshift=4cm]
  241. Bezier{0,0}{9,2}{-2,2}{7,0}
  242. end{scope}
  243. begin{scope}[yshift=-5cm]
  244. Bezier{0,0}{1,3}{2,3}{7,0}
  245. end{scope}
  246. begin{scope}[xshift=8cm,yshift=-5cm]
  247. Bezier{0,0}{-2,4}{4,-1}{5,0}
  248. end{scope}
  249. end{tikzpicture}
  250. end{document}
  251.  
  252. begin{tikzpicture}[thick]
  253. draw[help lines] (0,0) grid (3,2);
  254. node[draw=red, circle] (A) at (1,0) {A};
  255. node[draw=blue, rectangle] (B) at (2,2) {B};
  256. node[draw=green!60!black, circle] (C) at (3,1) {C};
  257. draw (A) to[spline through={(0,1)(B)(2,1)}] (C);
  258. end{tikzpicture}
  259.  
  260. begin{tikzpicture}[thick]
  261. draw[help lines] (0,0) grid (3,2);
  262. coordinate (A) at (1,0);
  263. coordinate (B) at (2,2);
  264. coordinate (C) at (3,1);
  265.  
  266. draw (A) to[spline coordinates=S,
  267. closed spline through={(0,1)(B)(2,1)(C)}] (A);
  268. foreach i [evaluate=i as j using i+1] in {1,2,...,tikzsplinesegments} {
  269. draw[semithick] (S K-i) -- (S P-i)
  270. (S K-j) -- (S Q-i);
  271. path[fill=green!60!black] (S P-i) circle (2pt);
  272. path[fill=red] (S Q-i) circle (2pt);
  273. }
  274. end{tikzpicture}
Add Comment
Please, Sign In to add comment