# How to Give an Elliptical Border a Braided Effect

Consider the code

\documentclass{book}
\usepackage{graphicx}
\usepackage[abs]{overpic}
\usepackage{tikz}
\definecolor{cadmiumgreen}{rgb}{0.0, 0.42, 0.235} % 0, 107, 60
\definecolor{Gold}{RGB}{228,168,73}

\begin{document}
\thispagestyle{empty}
\begin{center}
\begin{tikzpicture}
\clip (0,0) ellipse (4.25cm and 5.5cm);

\draw[line width=5pt,Gold,fill=cadmiumgreen!93.5] ellipse (4.25cm and 5.5cm);
\node at (0,0) {\includegraphics[scale=.37,clip, trim = 0 0 0 0]{example-image-a}};
\draw[line width=10.5pt,Gold] ellipse (4.25cm and 5.5cm);
\end{tikzpicture}
\end{center}
\end{document}


which produces the image QUESTION: I would like to give the gold border a braided effect. Does anyone know how this might be accomplished?

Thank you.

• Possibly a combination two paths with the snake decoration and the spath3/braids/knots libraries but I don't think it's that straight forward. Dec 22, 2022 at 10:50
• @Qrrbrbirlbel Thank you for the suggestion. Dec 22, 2022 at 10:56
• snake is annoying. I think it is better to use a parametrized plot of an ellipse, say ({xr*(1+.1*sin(\x*40))*cos \x}, {yr*(1+.1*sin(\x*40))*sin \x}) where xr and yr are the radii and \x is the angle (from 0 to 360). This gives you two wavey ellipses at least. Putting these as \strands however doesn't seem to lead to the desired result. Either it's too many points or the closed path don't work so nicely with knots. Dec 22, 2022 at 11:32 I don't know what you mean by "braided effect". I made a wild guess: something like an old picture frame. But details can be changed...

I define a decoration, mainly, taking two arguments: the number of steps (of the effect) and the width of the line to which the decoration is applied. Both are used as dimensions in points afterwards.

Remark It works better with closed curves.

The code

\documentclass[11pt, border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math, calc}
\usetikzlibrary{decorations.markings}

\definecolor{Gold}{RGB}{228, 168, 53}
\definecolor{DarkGold}{RGB}{221, 137, 53}
\begin{document}

\tikzset{%
braid/.style 2 args={% nb of steps, width in pts
preaction={draw=DarkGold, line width=#2pt},
decoration={%
markings,
mark=between positions 0 and 1 step 1/#1 with {
\tikzmath{%
\dl = \pgfdecoratedpathlength/#1;
{
\draw[DarkGold, line width=#2/13 pt, fill=Gold,
rounded corners=5pt, rotate=-40]
(.4*\dl pt, 0) rectangle ++(.7*\dl pt, .8*#2 pt);
\draw[DarkGold, line width=#2/10 pt, fill=Gold,
rounded corners=3pt, rotate=20]
(0, -.3*#2 pt) rectangle ++(\dl pt -1pt, .7*#2 pt);
};
}
}
},
postaction=decorate
}
}

\begin{tikzpicture}
ellipse (4.25cm and 5.5cm);
\end{tikzpicture}

\end{document}

• Many thanks for this fine answer! Dec 22, 2022 at 14:12
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}[
line width=8.3pt,
declare function={
rx=4.25;
ry=5.5;
n=10;
da=180/n;
ex1=(rx+0.2*cos(n*\t))*cos(\t);
ey1=(ry+0.2*cos(n*\t))*sin(\t);
ex2=(rx+0.2*cos(n*\t+120))*cos(\t);
ey2=(ry+0.2*cos(n*\t+120))*sin(\t);
ex3=(rx+0.2*cos(n*\t+240))*cos(\t);
ey3=(ry+0.2*cos(n*\t+240))*sin(\t);
},
samples=10, smooth, variable=\t,
]
\foreach \i [parse=true] in {0,...,(2*n-1)}{
\draw[orange!95!black] plot[domain=(\i-3/3)*da:(\i+0/3)*da+0.2] (ex1,ey1);
\draw[orange!85!black] plot[domain=(\i-2/3)*da:(\i+1/3)*da+0.2] (ex2,ey2);
\draw[orange!75!black] plot[domain=(\i-1/3)*da:(\i+2/3)*da+0.2] (ex3,ey3);
}
\clip (0,0) rectangle (rx,-ry);
\foreach \i [parse=true] in {(2*n)}{
\draw[orange!95!black] plot[domain=(\i-3/3)*da:(\i+0/3)*da+0.2] (ex1,ey1);
\draw[orange!85!black] plot[domain=(\i-2/3)*da:(\i+1/3)*da+0.2] (ex2,ey2);
\draw[orange!75!black] plot[domain=(\i-1/3)*da:(\i+2/3)*da+0.2] (ex3,ey3);
}
\end{tikzpicture}
\end{document}

• +1 Many thanks for posting this. Dec 22, 2022 at 19:57
• I can only say that TSE users are so fantastic! Dec 23, 2022 at 21:27

Here's an alternative in Metapost using a routine I wrote earlier that draws any path as a rope (sort of). This is wrapped up in luamplib so you need to compile it with lualatex.

\documentclass[border=5mm]{standalone}
\usepackage{graphicx}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef rope expr c =  % c is a circular path...
save s, w, n, a, b, A;
numeric s, w, n, A;
w = -1; n = -1; A = arclength c; s = A/floor(A/2);
path a[];
for t=0 step s until A + 1:
a[incr n] = (0,+w) rotated angle direction arctime t-3/2s of c of c shifted point arctime t-3/2s of c of c
.. (0,+w) rotated angle direction arctime t-1/2s of c of c shifted point arctime t-1/2s of c of c
.. (0,-w) rotated angle direction arctime t+1/2s of c of c shifted point arctime t+1/2s of c of c
.. (0,-w) rotated angle direction arctime t+3/2s of c of c shifted point arctime t+3/2s of c of c;
endfor
image(
for i=1 upto n:
path b; b = buildcycle(a[i-1], reverse a[i]);
fill b withcolor 1/2[white, gold];
draw b withpen pencircle scaled 1/8 withcolor gold;
endfor
)
enddef;

gold = 1/256(228, 168, 72);

beginfig(1);

path frame; frame = fullcircle scaled 5cm xscaled 17/22;

Adjust the value of w to make the rope thicker, and to flip between cable-laid and hawser-laid. -1 gives you a good looking cable (which is usually used for decoration), 1 gives the other direction. -2 looks a bit fatter.