4

I am trying to add some randomness to a double arc using random steps. The top and bottom endpoints of the arc are not at the same angles as the same arc drawn normally.

Random double arc

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{rough/.style={decorate,decoration={random steps,segment length=6pt}}}
\begin{document}
\begin{tikzpicture}
\draw[double distance=1cm, double=yellow, rough, color=red] (0,0) arc (0:90:3);
\draw[line width=0.01cm] (0,0) arc (0:90:3) -- (-3,0) -- cycle;
\end{tikzpicture}
\end{document}

I want the following angles at the endpoints, with random steps in between:

smooth double arc

How do I make the double arc's endpoints perfectly horizontal and vertical (preferably in a way that works with any amplitude and segment length)?

  • 2
    Draw little extra and Use clip to crop it – nidhin Aug 12 '19 at 14:57
6

One way is to draw little extra double arc and crop it using clip. In order to draw little longer double arc, polar coordinates are used.

\draw[double distance=1cm, double=yellow, rough, color=red] (-10:3) arc (-10:100:3);

A rectanglar cropping is done using clip.

\clip (0,0) rectangle (4,4);

enter image description here

See MWE below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{rough/.style={decorate,decoration={random steps,segment length=6pt}}}
\begin{document}
\begin{tikzpicture}
\begin{scope}[xshift=-3cm] % <-added
\clip (0,0) rectangle (4,4); % <-added
\draw[double distance=1cm, double=yellow, rough, color=red] (-10:3) arc (-10:100:3);% <-changed
\end{scope}
\draw[line width=0.01cm] (0,0) arc (0:90:3) -- (-3,0) -- cycle;
\end{tikzpicture}
\end{document}

EDIT

Triangular clipping can be used for clipping other angle ranges.

Example:

\clip (0:0) -- (10:6) -- (80:6)--cycle;

and

\clip (0:0) -- (30:6) -- (60:6)--cycle;

produces following output.

enter image description here

  • Thank you for this solution! Is it possible to cleanly clip the arc in a way that works for other angle ranges (-30:30 degrees for example)? – anonymous_pigeon Aug 12 '19 at 16:02
  • 1
    @anonymous_pigeon yes. In that case clipping path has to be changed from rectangle to required shape (double arc). – nidhin Aug 12 '19 at 16:07
5

Just for fun: a reminder that one can switch on and off decorations along a path.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{rough/.style={decoration={random steps,segment length=6pt}}}
\begin{document}
\begin{tikzpicture}
\draw[red,fill=yellow, rough] (0.5,0) decorate {arc (0:90:3.5)} 
 -- ++(0,-1) 
decorate {arc(90:0:2.5)} -- cycle ;
\draw[line width=0.01cm] (0,0) arc (0:90:3) -- (-3,0) -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.