# Easiest way to fill the region defined by a number of paths

I have a number of paths, quad-circles in this case, which intersect to define a complex region in the middle of the graph. How do I fill the A - B - C - D region in the image below? I prefer a solution that makes no assumptions on the formulation of the paths, i.e.: they can be Bezier curves with random control points instead of quadrant of a circle.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through}

\begin{document}
\begin{tikzpicture}
\path[draw,clip] (0,0) rectangle (6,6);
\node(circle 1)[draw, circle through={(6,0)}] at (0,0) {};
\node(circle 2)[draw, circle through={(0,0)}] at (6,0) {};
\node(circle 3)[draw, circle through={(6,0)}] at (6,6) {};
\node(circle 4)[draw, circle through={(0,0)}] at (0,6) {};

\coordinate[label=A](A) at (intersection 2 of circle 1 and circle 2);
\coordinate[label=B](B) at (intersection 1 of circle 1 and circle 4);
\coordinate[label=C](C) at (intersection 2 of circle 3 and circle 4);
\coordinate[label=D](D) at (intersection 2 of circle 2 and circle 3);
\end{tikzpicture}
\end{document} • possibly helpful starting point(?): Tikz: joining points on a circle – cmhughes Nov 12 '13 at 3:15
• Thanks for the suggestion, but all answers on that question assumes that the path is an arc. I'm looking for a solution that makes no such assumptions. – Code Different Nov 12 '13 at 3:21
• Even more clipping: Tikz: shading region bounded by several curves – Qrrbrbirlbel Nov 12 '13 at 3:44
• +1 I didn't find this syntax (intersection 2 of circle 1 and circle 2) in the manual 3.0.1a, neither in the 2.10 nor in the 1.18, where does it come from? – AndréC Dec 16 '18 at 19:52 This Asymptote solution uses a function ABCD defined in asydef environment to draw a region of bounded by the four consecutively intersecting paths. However, some order of intersection is assumed. If the paths are absolutely random, (may not intersect, for example) than more checking is needed.

%
% xsect.tex :
%
\documentclass[10pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{lmodern}
\usepackage{subcaption}
\usepackage[inline]{asymptote}
\begin{asydef}
void ABCD(guide AB, guide BC, guide CD, guide DA
,pen linepen=deepblue+1.2bp
,pen areapen=red+1.4bp
,pen fillpen=palegreen){

real tA[], tB[], tC[], tD[];
pair A,B,C,D;

tA=intersect(AB,DA); // tA - AB time of intersection, t - DA time of intersection
tB=intersect(BC,AB); // tB - BC time of intersection, t - AB time of intersection
tC=intersect(CD,BC); // tC - CD time of intersection, t - BC time of intersection
tD=intersect(DA,CD); // tD - DA time of intersection, t - CD time of intersection

A=point(AB,tA);
B=point(BC,tB);
C=point(CD,tC);
D=point(DA,tD);

guide area=buildcycle(AB,BC,CD,DA);

draw(AB^^BC^^CD^^DA,linepen);
filldraw(area,fillpen,areapen);

label("$A$",A,2N);
label("$B$",B,2W);
label("$C$",C,2S);
label("$D$",D,2E);

dot(new pair[]{A,B,C,D},UnFill);
}
\end{asydef}
%
\begin{document}
%
\begin{figure}
\captionsetup[subfigure]{justification=centering}
\centering
\begin{subfigure}{0.49\textwidth}
\begin{asy}
size(200);
ABCD(
arc(( 1,-1),2, 90,180)
,arc(( 1, 1),2,180,270)
,arc((-1, 1),2,-90,  0)
,arc((-1,-1),2,  0, 90)
);
\end{asy}
%
\caption{}
\label{fig:1a}
\end{subfigure}
%
\begin{subfigure}{0.49\textwidth}
\begin{asy}
size(200);
ABCD(
(1,2)..(-1.2,0.1)..(-1.7,-1.8)
,(-2,1)..(-1,1)..(-0.5,0)..(0.5,-0.8)
,arc((-1, 1),2,-90,  0)
,(2,-1)..(2,0)..(0.5,1)..(0,1.7)
,olive+0.4bp
,orange+1.3bp
,lightyellow
);
\end{asy}
%
\caption{}
\label{fig:1b}
\end{subfigure}
\caption{}
\label{fig:1}
\end{figure}
%
\end{document}
%
% Process :
%
% pdflatex xsect.tex
% asy xsect-*.asy
% pdflatex xsect.tex


With PSTricks. Intersection is not necessary in this case as a simple logic can help you to find the angles at which the arcs start and stop. See the following explanation how to calculate the angles. \documentclass[pstricks,border=12pt]{standalone}

\degrees
\psset{dimen=monkey}

\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\psframe(-3,-3)(3,3)
\pscustom*[linecolor=yellow]
{
\foreach \x/\y/\a in {-3/-3/1, 3/-3/4, 3/3/7, -3/3/10}
}
\foreach \x/\y/\a in {-3/-3/0, 3/-3/3, 3/3/6, -3/3/9}
\end{pspicture}
\end{document} ## Miscellaneous

By changing {!\a\space 3 add} to {!\a\space 2 add}, we get a lens diaphragm.

\documentclass[pstricks,border=12pt]{standalone}

\degrees
\psset{dimen=monkey}

\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\psframe(-3,-3)(3,3)
\pscustom*[linecolor=yellow]
{
\foreach \x/\y/\a in {-3/-3/1, 3/-3/4, 3/3/7, -3/3/10}
}
\foreach \x/\y/\a in {-3/-3/0, 3/-3/3, 3/3/6, -3/3/9}
\end{pspicture}
\end{document} Another approach by TikZ, where simple logic suggested by Marienplatz is applied. Thanks

Here the origin of circle 1 is my reference point and draw the first arc. What follows then is a pattern of 90 degree difference is repeated because this is how the remaining circles are drawn. Code

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through}

\begin{document}
\begin{tikzpicture}
\path[draw,clip] (0,0) rectangle (6,6);
\node(circle 1)[draw, very thick,circle through={(6,0)}] at (0,0) {};
\node(circle 2)[draw, very thick,circle through={(0,0)}] at (6,0) {};
\node(circle 3)[draw, very thick,circle through={(6,0)}] at (6,6) {};
\node(circle 4)[draw, very thick,circle through={(0,0)}] at (0,6) {};
\coordinate[label=A](A) at (intersection 2 of circle 1 and circle 2);
\coordinate[label=B](B) at (intersection 1 of circle 1 and circle 4);
\coordinate[label=C](C) at (intersection 2 of circle 3 and circle 4);
\coordinate[label=D](D) at (intersection 2 of circle 2 and circle 3);
\fill[red] (30:6) arc (30:60:6) arc (120:150:6) arc(210:240:6) arc(300:330:6);
%\draw [black,thick] (30:6) arc (30:60:6) arc (120:150:6) arc(210:240:6) arc(300:330:6);
\end{tikzpicture}
\end{document}