Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass[tikz,border=10pt,multi]{standalone}
- begin{document}
- begin{tikzpicture}
- draw (0,0) .. controls (1,1) and (2,-1) .. (3,0);
- end{tikzpicture}
- end{document}
- draw (0,0) .. controls (??,??) and (??,??) .. (3,0);
- documentclass[parskip=full]{scrartcl}
- usepackage[margin=2cm,paperheight=40cm]{geometry}
- usepackage{tikz}
- newcommandDrawControl[3]{
- node[#2,circle,fill=#2,inner sep=2pt,label={above:$#1$},label={[black]below:{footnotesize#3}}] at #1 {}
- }
- pagestyle{empty}
- begin{document}
- centering
- One control point:\
- begin{tikzpicture}[baseline]
- draw[help lines] (0,0) grid (8,5);
- draw[ultra thick]
- (1,0)
- .. controls (4,0) ..
- (7,0) DrawControl{(4,0)}{black}{};
- draw[ultra thick,blue]
- (1,0)
- .. controls (4,2) ..
- (7,0) DrawControl{(4,2)}{blue}{};
- draw[ultra thick,red]
- (1,0)
- .. controls (4,6) ..
- (7,0) DrawControl{(4,6)}{red}{};
- end{tikzpicture}hfill
- begin{tikzpicture}[baseline]
- draw[help lines] (0,0) grid (8,5);
- draw[ultra thick]
- (1,0)
- .. controls (2,0) ..
- (7,0) DrawControl{(2,0)}{black}{};
- draw[ultra thick,blue]
- (1,0)
- .. controls (2,2) ..
- (7,0) DrawControl{(2,2)}{blue}{};
- draw[ultra thick,red]
- (1,0)
- .. controls (2,6) ..
- (7,0) DrawControl{(2,6)}{red}{};
- end{tikzpicture}
- rule{textwidth}{2pt}
- Two control points:\
- begin{tikzpicture}[baseline]
- draw[help lines] (0,0) grid (8,3);
- draw[ultra thick,blue]
- (1,0)
- .. controls (3,2) and (5,2) ..
- (7,0) DrawControl{(3,2)}{blue}{1}DrawControl{(5,2)}{blue}{2} ;
- draw[ultra thick,red]
- (1,0)
- .. controls (3,4) and (5,4) ..
- (7,0) DrawControl{(3,4)}{red}{1}DrawControl{(5,4)}{red}{2};
- end{tikzpicture}hfill
- begin{tikzpicture}[baseline]
- draw[help lines] (0,0) grid (8,3);
- draw[ultra thick,blue]
- (1,0)
- .. controls (2,2) and (6,2) ..
- (7,0) DrawControl{(2,2)}{blue}{1}DrawControl{(6,2)}{blue}{2};
- draw[ultra thick,red]
- (1,0)
- .. controls (2,4) and (6,4) ..
- (7,0) DrawControl{(2,4)}{red}{1}DrawControl{(6,4)}{red}{2};
- end{tikzpicture}
- rule{textwidth}{2pt}
- vspace{3cm}
- begin{tikzpicture}[baseline]
- draw[help lines] (0,0) grid (8,3);
- draw[overlay,ultra thick,blue]
- (1,0)
- .. controls (10,2) and (-2,2) ..
- (7,0) DrawControl{(10,2)}{blue}{1}DrawControl{(-2,2)}{blue}{2};
- draw[overlay,ultra thick,red]
- (1,0)
- .. controls (12,4) and (-4,4) ..
- (7,0) DrawControl{(12,4)}{red}{1}DrawControl{(-4,4)}{red}{2};
- end{tikzpicture}
- rule{textwidth}{2pt}
- begin{tikzpicture}[baseline]
- draw[help lines] (0,-2) grid (8,2);
- draw[ultra thick,blue]
- (1,0)
- .. controls (3,2) and (5,-2) ..
- (7,0) DrawControl{(3,2)}{blue}{1}DrawControl{(5,-2)}{blue}{2};
- draw[ultra thick,red]
- (1,0)
- .. controls (-1,5) and (8,-5) ..
- (7,0) DrawControl{(-1,5)}{red}{1}DrawControl{(8,-5)}{red}{2};
- end{tikzpicture}
- rule{textwidth}{2pt}
- end{document}
- draw (0,0) .. controls (??,??) and (??,??) .. (3,0);
- draw (0,0) .. controls (1,2) and (2,-2) .. (3,0);
- tikz-bezier-animation.tex
- documentclass[tikz]{standalone}
- usetikzlibrary{decorations.pathreplacing,backgrounds}
- tikzset{
- show curve controls/.style={
- decoration={
- show path construction,
- curveto code={
- draw[#1!50]
- (tikzinputsegmentfirst)
- -- (tikzinputsegmentsupporta)
- -- (tikzinputsegmentsupportb)
- -- (tikzinputsegmentlast)
- ;
- fill[#1!50] (tikzinputsegmentsupporta) circle(1pt);
- fill[#1!50] (tikzinputsegmentsupportb) circle(1pt);
- draw[#1,line width=1pt]
- (tikzinputsegmentfirst)
- .. controls (tikzinputsegmentsupporta)
- and (tikzinputsegmentsupportb) ..
- (tikzinputsegmentlast);
- }
- },decorate
- }
- }
- begin{document}
- foreach p in {0,10,...,360} {
- begin{tikzpicture}
- begin{scope}
- path (-4,-2) rectangle (4,2.1);
- coordinate (a) at (-2,0);
- coordinate (b) at (2,0);
- path (a) ++(1,0) ++(p:0 and 2) coordinate (a1);
- path (b) ++(-1,0) ++({180-p}:0 and 2) coordinate (b1);
- draw[show curve controls={red}] (a) .. controls (a1) and (b1) .. (b);
- end{scope}
- begin{scope}[yshift=-4.5cm]
- path (-4,-1) rectangle (4,4);
- coordinate (a) at (-2,0);
- coordinate (b) at (2,0);
- path (a) ++(45:3) ++(p:3 and 0) coordinate (a1);
- path (b) ++(90+45:3) ++(180-p:3 and 0) coordinate (b1);
- draw[show curve controls={blue}] (a) .. controls (a1) and (b1) .. (b);
- end{scope}
- begin{scope}[yshift=-6cm]
- path (-4,-3) rectangle (4,4);
- coordinate (a) at (-2,0);
- coordinate (b) at (2,0);
- path (a) ++(1,0) [rotate=45] ++(p:0 and 2) coordinate (a1);
- path (b) ++(-1,0) [rotate=45] ++({180+p}:0 and 2) coordinate (b1);
- draw[show curve controls={green!50!black}]
- (a) .. controls (a1) and (b1) .. (b);
- end{scope}
- begin{pgfonlayer}{background}
- fill[white] (current bounding box.south west)
- rectangle (current bounding box.north east);
- end{pgfonlayer}
- end{tikzpicture}
- }
- end{document}
- documentclass[tikz,border=5]{standalone}
- usetikzlibrary{decorations.pathreplacing}
- tikzset{%
- show curve controls/.style={
- postaction={
- decoration={
- show path construction,
- curveto code={
- draw [blue]
- (tikzinputsegmentfirst) -- (tikzinputsegmentsupporta)
- (tikzinputsegmentlast) -- (tikzinputsegmentsupportb);
- fill [red, opacity=0.5]
- (tikzinputsegmentsupporta) circle [radius=.5ex]
- (tikzinputsegmentsupportb) circle [radius=.5ex];
- }
- },
- decorate
- }}}
- begin{document}
- begin{tikzpicture}
- draw [help lines] (-4, -1) grid (4, 5);
- draw [show curve controls]
- (-3, 4) .. controls ++(135:-1) and ++(135:1) .. (0, 4);
- draw [show curve controls] (0, 0)
- .. controls ++(165:-1) and ++(240: 1) .. ( 3, 2)
- .. controls ++(240:-1) and ++(165:-1) .. ( 2, 4)
- .. controls ++(165: 1) and ++(175:-2) .. (-1, 2)
- .. controls ++(175: 2) and ++(165: 1) .. ( 0, 0);
- end{tikzpicture}
- end{document}
- documentclass[border=5pt,tikz]{standalone}
- tikzset{
- ctrlpoint/.style={%
- draw=gray,
- circle,
- inner sep=0,
- minimum width=1ex,
- }
- }
- newcommandBezier[4]{% bezier (lowercase 'b') was already defined elsewhere
- node (p1) [ctrlpoint,label=90:$P_1$] at (#1) {};
- node (p2) [ctrlpoint,label=90:$P_2$] at (#2) {};
- node (p3) [ctrlpoint,label=90:$P_3$] at (#3) {};
- node (p4) [ctrlpoint,label=90:$P_4$] at (#4) {};
- draw [gray] (p1) -- (p2) -- (p3) -- (p4);
- draw [blue] (#1) .. controls (#2) and (#3) .. (#4);
- }
- begin{document}
- begin{tikzpicture}
- Bezier{0,0}{1,1}{2,-1}{3,0}
- begin{scope}[xshift=4cm]
- Bezier{0,0}{9,2}{-2,2}{7,0}
- end{scope}
- begin{scope}[yshift=-5cm]
- Bezier{0,0}{1,3}{2,3}{7,0}
- end{scope}
- begin{scope}[xshift=8cm,yshift=-5cm]
- Bezier{0,0}{-2,4}{4,-1}{5,0}
- end{scope}
- end{tikzpicture}
- end{document}
- begin{tikzpicture}[thick]
- draw[help lines] (0,0) grid (3,2);
- node[draw=red, circle] (A) at (1,0) {A};
- node[draw=blue, rectangle] (B) at (2,2) {B};
- node[draw=green!60!black, circle] (C) at (3,1) {C};
- draw (A) to[spline through={(0,1)(B)(2,1)}] (C);
- end{tikzpicture}
- begin{tikzpicture}[thick]
- draw[help lines] (0,0) grid (3,2);
- coordinate (A) at (1,0);
- coordinate (B) at (2,2);
- coordinate (C) at (3,1);
- draw (A) to[spline coordinates=S,
- closed spline through={(0,1)(B)(2,1)(C)}] (A);
- foreach i [evaluate=i as j using i+1] in {1,2,...,tikzsplinesegments} {
- draw[semithick] (S K-i) -- (S P-i)
- (S K-j) -- (S Q-i);
- path[fill=green!60!black] (S P-i) circle (2pt);
- path[fill=red] (S Q-i) circle (2pt);
- }
- end{tikzpicture}
Add Comment
Please, Sign In to add comment