
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{positioning}
\usetikzlibrary{matrix,arrows,calc,shapes}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{matrix}

\definecolor{myblue}{cmyk}{1.00,0.56,0.00,0.34}
\definecolor{mygreen}{cmyk}{0.5,0,0.5,0.5}
\definecolor{myred}{cmyk}{0.00,1.00,0.63,0.00}

\usetikzlibrary{arrows,automata}

\usetikzlibrary{decorations.pathreplacing,decorations.markings}

\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{stealth}}},postaction={decorate}}}


\tikzset{
  % style to apply some styles to each segment of a path
  on each segment/.style={
    decorate,
    decoration={
      show path construction,
      moveto code={},
      lineto code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
      curveto code={
        \path [#1] (\tikzinputsegmentfirst)
        .. controls
        (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
        ..
        (\tikzinputsegmentlast);
      },
      closepath code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
    },
  },
  % style to add an arrow in the middle of a path
  mid arrow/.style={postaction={decorate,decoration={
        markings,
        mark=at position .5 with {\arrow[#1]{stealth}}
      }}},
}
% for drawing triangulation on strip
\def\Prufer#1#2#3#4{
	\coordinate (x) at (#1,#2);
	\fill (x) circle (.1);
	\draw[#4] (x) .. controls (#1,#2+2.5) and (#1+.5,#2+3) .. (#1+#3,#2+3);
}

\def\adic#1#2#3#4{
	\coordinate (x) at (#1,#2);
	\fill (x) circle (.1);
	\draw[#4] (x) .. controls (#1,#2+2.5) and (#1-.5,#2+3) .. (#1-#3,#2+3);
}

\def\hadic#1#2#3#4{
	\coordinate (x) at (#1,#2);
	\fill (x) circle (.1);
	\draw[#4] (x) .. controls (#1,#2-2.5) and (#1+.5,#2-3) .. (#1+#3,#2-3);
}

\def\hPrufer#1#2#3#4{
	\coordinate (x) at (#1,#2);
	\fill (x) circle (.1);
	\draw[#4] (x) .. controls (#1,#2-2.5) and (#1-.5,#2-3) .. (#1-#3,#2-3);
}
\newcommand\PruferShort[4]{
	\coordinate (x) at (#1,#2);
	\fill (x) circle (.1);
	\draw[#4] (x) .. controls (#1,#2+4) and (#1+.1,#2+4) .. (#1+#3,#2+3.8);
}

\newcommand\PruferShortCurvedLeft[4]{
	\coordinate (x) at (#1,#2);
	\fill (x) circle (.1);
	\draw[#4] (x) .. controls (#1,#2+4) and (#1-.1,#2+4) .. (#1-#3,#2+3.8);
}

%%%%
%%% ordinary triangle %%%%
\newcommand\MacroTriangle{
\draw[thick]
(0,0) -- (4,0) -- (2,4) -- (0,0);
\draw [fill=olive] (0,0) circle (.6ex);
\draw [fill=olive] (4,0) circle (.6ex);
\draw [fill=olive] (2,4) circle (.6ex);
}
\newcommand\TikzTriangle[1]{
\begin{tikzpicture}[scale={#1} ]
\MacroTriangle
\node at (4.5,0) {}; \node at (-0.5,0) {};
\end{tikzpicture}
}

%%% triangle with two vertices and three sides %%%%

\newcommand\MacroTwoVertexTriangle{ % the outer side
\draw[style = thick]%, rounded corners = 20pt]
	(0,0) .. controls (-1.7,1) and (-1.6,3) .. (0,3.5) ..
	controls (1.6,3)  and (1.7,1) .. (0,0);
	\draw [fill=olive] (0,0) circle (.6ex);
	\draw [fill=olive] (0,3.5) circle (.6ex);

\draw[style = thick, rounded corners = 20pt] % inner loop
	(0,0) .. controls (-0.8,1) and (-0.5,1.7) .. (0,2.5) ..
	controls (0.5,1.7)  and (0.8,1) .. (0,0);
}
\newcommand\TikzTwoVertexTriangle[1]{ % NEED
\begin{tikzpicture}[scale={#1} ]
\MacroTwoVertexTriangle
\end{tikzpicture}
}


%%% triangle with one vertex and three sides %%%%

\newcommand\MacroVeryThinNoose{
\draw[style = thick, rounded corners = 10pt] % inner loop
	(0,0) .. controls (-0.6,1) and (-0.4,1.7) .. (0,2.2) ..
	controls (0.4,1.7)  and (0.6,1) .. (0,0);
}

\newcommand\MacroVeryThinNooseHidden{
\draw[style = thick, rounded corners = 5pt] % inner loop
	(0,0) .. controls (-0.6,1) and (-0.4,1.7) .. (0,2) ..
	controls (0.4,1.7)  and (0.6,1) .. (0,0);
}

\newcommand\MacroOneVertexTriangle{
\draw[style = thick, rounded corners = 30pt]
	(0,0) .. controls (-2.7,1) and (-2.4,2.5) .. (0,3.5) ..
	controls (2.4,2.5)  and (2.7,1) .. (0,0);
	
	\draw [fill=olive] (0,0) circle (.6ex);
	
\begin{scope}[rotate=30]
\MacroVeryThinNoose
\end{scope}

\begin{scope}[rotate=-35]
\MacroVeryThinNoose
\end{scope}
}

\newcommand\MacroOneVertexTriangleHidden{
    \begin{scope}[rotate=30]
    \MacroVeryThinNooseHidden \end{scope}

    \begin{scope}[rotate=-35]
    \MacroVeryThinNooseHidden \end{scope}

    \begin{scope}[rotate=-100]
    \MacroVeryThinNooseHidden \end{scope}

    \draw [fill=olive] (0,0) circle (.6ex);
}

\newcommand\TikzOneVertexTriangle[1]{ % NEED
\begin{tikzpicture}[scale={#1} ]
\MacroOneVertexTriangle
\end{tikzpicture}
}

% NEED

\newcommand\MacroSelfFoldedTriangleNoLabel{
	\draw[thick]
	(0,0) -- (0,2);
	
	\draw [fill=violet] (0,2) circle (1.2*\TikzPunctureActualSize);
	
	\draw[style = thick, rounded corners = 20pt]
	(0,0) .. controls (-1.8,1) and (-1.5,2.5) .. (0,3.5) ..
	controls (1.5,2.5)  and (1.8,1) .. (0,0); %node[pos=0.5, right] {$\ell$};
	\draw [fill=olive] (0,0) circle (.6ex);
}
\newcommand\TikzSelfFoldedTriangle[1]{ 
\begin{tikzpicture}[scale={#1} ]
\MacroSelfFoldedTriangleNoLabel
\draw (-1.6,2) node {$\ell$};
\draw (0.3,1) node {$r$};
\end{tikzpicture}
}

\newcommand\TikzPunctureActualSize{0.1} 
\newcommand\TikzPointActualSize{0.07}

