The source of the difficulty is that ellipses are constructed in a particular way in TikZ. They are paths that start from the x-axis and proceed counter-clockwise around their centre. The vast majority of the time, the exact parametrisation doesn't matter. You appear to have found the one situation where it does!
In the actual question, you only want to be able to mirror the ellipse, and so draw it starting from the negative x-axis (the title of the question suggests a more flexible approach). That's actually not too hard since we can exploit the symmetry of the ellipse. The key is to provide it with a negative x-radius, since then it will start from the negative x-axis (and proceed clockwise, but we could correct for that by negating the y-radius as well). To do this, we interrupt the call from the node shape to the drawing command and flip the sign of the x-radius. The simplest way to do this is to redefine the \pgfpathellipse
macro to do the negation and then call the original macro. The following code does this.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations,shapes,decorations.markings}
\makeatletter
\let\origpgfpathellipse=\pgfpathellipse
\def\revpgfpathellipse#1#2#3{%
#2%
\pgf@xa=-\pgf@x
\origpgfpathellipse{#1}{\pgfqpoint{\pgf@xa}{0pt}}{#3}}
\makeatother
\tikzset{
reversed ellipse/.style={
ellipse,
reverse the ellipse%
},
reverse the ellipse/.code={
\let\pgfpathellipse=\revpgfpathellipse
}
}
\begin{document}
\begin{tikzpicture}
\node[ellipse,
draw,
postaction={
decorate,
decoration={
markings,
mark=at position 1 with {
\arrow[line width=5pt,blue]{>}
}
}
}
] at (0,0) {hello world};
\node[reversed ellipse,
draw,
postaction={
decorate,
decoration={
markings,
mark=at position 1 with {
\arrow[line width=5pt,blue]{>}
}
}
}
] at (0,-2) {hello world};
\end{tikzpicture}
\end{document}
Here's the result:
![rotated ellipse](https://i.stack.imgur.com/wUjPy.png)
(the arrow got clipped, but you can see where it lies)
It is very easy to add some features like a domain and a dx
to the older version of the spiro
pic. I just focus on two of your screen shots for illustration, but think you can do all of them with the adjusted syntax. Please let me know if I am missing something.
\documentclass[tikz,border=3mm]{standalone}
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples}]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.005,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzpicture}[]
\draw
(0,0) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{pic[scale=0.5,draw=\X,ultra
thick]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}};
\draw(0,-7) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{foreach \Z in {0,...,5}
{pic[scale=0.5,draw=\X,ultra thick,fill=\X,fill
opacity=0.2,rotate=\Z*15]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}}};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/Kzij5.png)
Please note that the older version used smooth cycle
so one could get good results with a comparatively small number of samples. Here, on the other hand, I followed your instructions to connect the plot points by straight lines, so one needs more samples and longer time to compile. Please let me know if one should go back to the smooth
case to increase the speed. Doing that yields
\documentclass[tikz,border=3mm]{standalone}
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples},smooth]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.05,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzpicture}
\draw
(0,0) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{pic[scale=0.5,draw=\X,ultra
thick]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}};
\draw(0,-7) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{foreach \Z in {0,...,5}
{pic[scale=0.5,draw=\X,ultra thick,fill=\X,fill
opacity=0.2,rotate=\Z*15]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}}};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/OdHwB.png)
It appears natural to me to combine this with path fading.
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings,fadings}
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples},smooth]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.05,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzfadingfrompicture}[name=spiro]
\draw foreach \Y in {0,...,3}
{foreach \Z in {0,...,5}
{pic[scale=0.5,fill=transparent!60,
draw=transparent!20,
rotate=\Z*15]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/2+pi/9+\Y*pi/2}}}}};
\end{tikzfadingfrompicture}
\begin{tikzpicture}
\shade[shading=color wheel,
path fading=spiro,fit fading=false] (0,0) circle [radius=4cm];
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/kQSM4.png)
ADDENDUM: These are the requested graphs. I added some explanations to the code. Explaining something well requires the knowledge where the other user involved is struggling. I do not have this knowledge. If you ask specific questions, I will try to answer them.
\documentclass[tikz,border=3mm]{standalone}
% The following just sets up a plot where you can contol the parameters via pgf
% keys. The central object is the plot.
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples},smooth]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.08,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzpicture}
\path (0,0)
pic[scale=0.5,draw=yellow,ultra thick]{spiro2={dx=0.03}}
foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{pic[scale=0.5,draw=\X,ultra
thick]{spiro2={domain={-pi/12+\Y*pi/2}:{pi/12+\Y*pi/2}}}};
% This is a loop orgy. We loop over scale factors, overall rotations and colors.
\path[line cap=round] (7,0)
foreach \ScaleN
[evaluate=\ScaleN as \Scale using {pow(0.85,\ScaleN)/0.8}] % compute sale factor
in {1,...,5} %loop over scale
{foreach \Z in {0,...,3} %loop over 4 overall rotations
{foreach \X [count=\Y starting from 0] in
{yellow,orange,red,blue,purple,cyan,magenta,green!70!black} % colors
{pic[scale=0.5,draw=\X,rotate=\Y*90/8+\Z*90,
scale=\Scale,line width=\Scale*2pt]
{spiro2={domain={-pi/11.4}:{pi/11.4}}}}}};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/ZegHR.png)
Best Answer
Update 2
You can make the color of the decoration a parameter of the style.
Just call this style
pe=yellow
, by default these style is red.Update
If I understood correctly, you must specify the color in the decoration.