0

Is it possible to subtract one shape from another in Tikz?

I can then draw arc shape and subtract rectangular like shapes from it...

Like

Desired image

MrB
  • 3
  • 1
    A very warm welcome to TeX.SE! You should at least add the MWE to draw the initial shape with Tikz, if you are able. http://meta.tex.stackexchange.com/questions/3343/what-makes-a-good-mwe – A Feldman Jul 03 '16 at 10:52
  • See http://tex.stackexchange.com/questions/12010/how-can-i-invert-a-clip-selection-within-tikz. However, I think it would be easier to use a decoration here. – cfr Jul 03 '16 at 12:13

1 Answers1

3

Please remember that very nearly almost all questions should include a Minimal Working Example. Not only does this make it easier for people to help, it almost always ensures more effective and meaningful answers. That is, you are more likely to get help and likely to get better help.

I think I ought not answer this question, but I am going to do so anyway.


Sort of.


This answer does not provide a way to subtract (add, multiply or divide) paths. Inverse clipping is possible using one of the solutions on this site, such as some in the answers of the question I linked to in a comment on your question.

But that would not be an easy way to draw the kind of path pictured in the question. That would much more easily be done using a decoration.

For example,

\documentclass[border=10pt,tikz,multi]{standalone}
\usetikzlibrary{decorations}
\pgfdeclaredecoration{pit}{initial}{
  \state{initial}[width=5pt]
  {
    \pgfpathlineto{\pgfpoint{0}{-5pt}}
    \pgfpathlineto{\pgfpoint{5pt}{-5pt}}
    \pgfpathlineto{\pgfpoint{5pt}{0}}
  }
  \state{final}
  {
    \pgfpathmoveto{\pgfpointdecoratedpathlast}
  }
}
\pgfdeclaremetadecoration{pitfalls}{initial}{
  \state{initial}[width=7.5pt, next state=pitfall]
  {
    \decoration{curveto}
  }
  \state{pitfall}[switch if less than=7.5pt to final, switch if input segment less than=5pt to steady, width=5pt, next state=steady]
  {
    \decoration{pit}
  }
  \state{steady}[width=10pt, next state=pitfall]
  {
    \decoration{curveto}
  }
  \state{final}
  {
    \decoration{curveto}
  }
}
\begin{document}
\begin{tikzpicture}
    \path [thick, decorate, decoration={pitfalls}, draw=blue!50!cyan] (0,0) arc [start angle=180, end angle=90, radius=3] |- cycle;
\end{tikzpicture}
\end{document}

pitfalls in blue

cfr
  • 198,882
  • I didn't have a MWE because the idea was in my head, and I am still learning TIKZ :| But you helped me with your answer. – MrB Jul 03 '16 at 17:25