13

Please ignore the binary numbers.

enter image description here

Without finding the intersection points in advance, is it possible to fill the complement of (A union B union C) with a solid color but the remaining regions remain transparent?

3
  • 1
    You have 8 regions and you can draw each region seperately as a closed path. So a macro can receive 8 bit number and pass fill=blue option to the path if it's 1 or 0 at the specific digit. – percusse Aug 16 '12 at 13:28
  • @percusse: How can you get the 8 regions without finding the intersection points in advance? :-) – kiss my armpit Aug 16 '12 at 13:39
  • Using geometry is one option (assuming that the circles are the same for all three and have predefined coordinates). – percusse Aug 16 '12 at 13:40
16

Using the approach described in How can I invert a 'clip' selection within TikZ?:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\tikzstyle{reverseclip}=[insert path={(current page.north east) --
  (current page.south east) --
  (current page.south west) --
  (current page.north west) --
  (current page.north east)}
]

\begin{tikzpicture}[remember picture]

\draw [gray!20, ultra thick] (-3,-3) grid (3,3);

\begin{pgfinterruptboundingbox}
\path  [clip] (90:0.7cm) circle [radius=1cm] [reverseclip];
\path  [clip] (-30:0.7cm) circle [radius=1cm] [reverseclip];
\path  [clip] (210:0.7cm) circle [radius=1cm] [reverseclip];
\end{pgfinterruptboundingbox}

\fill [orange] (-2,-2) rectangle (2,2);
\end{tikzpicture}
\end{document}
5
  • I haven't known whether or not PSTricks has reverse clip. – kiss my armpit Aug 16 '12 at 14:09
  • I see you have defined a path around the whole page, can I use this path to fill the page with orange? – qed Oct 25 '13 at 10:45
  • @qed: Sure. You can use \fill [orange] (current page.north west) rectangle (current page.south east);. Note that you need to have the options remember picture, overlay in your tikzpicture options, and you need to compile the document twice. – Jake Oct 25 '13 at 11:04
  • why is it necessary to remember the position of current picture in this case? And what is the difference between current page and current picture? – qed Oct 25 '13 at 11:15
  • @qed: Take a look at section 16.13.2 "Referencing the Current Page Node" in the PGF manual. – Jake Oct 25 '13 at 11:17
7
+50

needs the latest pstricks.tex from http://texnik.dante.de/tex/generic/pstricks/ available on CTAN in a few days

\documentclass{minimal}
\usepackage{pstricks}\SpecialCoor

\begin{document}

\begin{pspicture}(-3,-3)(3,3)\psgrid[gridlabels=0pt]
  \pscustom[linestyle=none]{%
  \pspolygon(-2,-2)(-2,2)(2,2)(2,-2)
  \moveto(0.7;90)\rmoveto(1,0)\pscircle(0.7;90){1}
  \moveto(0.7;-30)\rmoveto(1,0)\pscircle(0.7;-30){1}
  \moveto(0.7;210)\rmoveto(1,0)\pscircle(0.7;210){1}
  \closepath
  \code{eoclip}
  \pspolygon(-2,-2)(-2,2)(2,2)(2,-2)
  \fill[fillcolor=blue!60,fillstyle=solid,linestyle=none]}
\end{pspicture}

\end{document}

but there are still some small lines for the circles:

enter image description here

5
  • Can PSTricks have reverse clip feature as Tikz? – kiss my armpit Aug 21 '12 at 13:09
  • sure, needs only one who implements it ... – user2478 Aug 21 '12 at 13:17
  • I have not seen your PSTricks book because it is not available on the bookstore. Amazon.com also does not provide us with its table of contents. My question: what is the difference between the PSTricks package manuals and your PSTricks book? I am interested to know the details about PSTricks programming for hackers only (TVZ's manual on printed page number 38) and creating low/high level objects (TVZ's manual on printed page number 163-). Are both these topics elaborated in your PSTricks book? – kiss my armpit Aug 21 '12 at 13:39
  • see archiv.dante.de/~herbert/Books – user2478 Aug 21 '12 at 14:12
  • How to completely remove the unwanted thin but visible paths? – kiss my armpit Oct 25 '13 at 8:59

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.