Two-Coloring Overlapping Circles Write a program or function that takes in the following input in a reasonable format of your choice:


Two positive integers W and H that define the width and height of the image you'll be generating.
Two RGB colors C1 and C2 that will be used to color the image.
A list of 3-tuples of the form (r, x, y) that define circles with radius r and center x, y in the plane of the image. r is a positive integer and x and y are any integers. The top left pixel of the image is 0, 0 and the x-axis increases to the right and the y-axis increases downward.


Output an image with dimensions W by H that is colored with C1 and C2 such that no two neighboring regions defined by all the overlapping circles are the same color.


  For example: If the input is

W = 300
H = 200
C1 = (255, 200, 0)
C2 = (128, 0, 255)
Circles = (25, 50, 80), (40, 80, 120), (300, -100, 6), (17, 253, 162)

  
  then the circle boundaries look like this:
  
  
  
  There are six distinct, contiguous regions in the image created by the
  circles. Each region must be colored with C1 (yellow) or C2 (purple)
  such that no two neighboring regions are the same color.
  
  There are two ways to do this, their only difference being that the
  colors are swapped:
  
   
  
  Thus, either of these two images would be valid output for the example
  input.
  
  Something like this would be invalid output since two yellow regions
  neighbor each other.


Your output images should follow these guidelines:


Besides C1 and C2, a third, neutral color such as black or white may be used for circle boundaries as long as they are no more than 5 pixels thick. (Black, 1-pixel thick boundaries are present in the example above.)
Circles boundaries are not required, however. The regions may neighbor each other directly:

 

Both of these is another valid output to the example above.
Circles should be as accurate as reasonably possible, using circle drawing algorithms or whatever your graphics library provides.
In general, pixel-perfection is not required, but if the input parameters are scaled equally larger and larger, the resulting image should become more and more accurate.
Anti-aliasing is allowed but not required.
Gridlines or axis labels etc. in the background are not allowed.


The shortest code in bytes wins.

More Examples

All using these inputs with different sets of circles:

W = 100
H = 60
C1 = (255, 0, 0)
C2 = (0, 0, 255)


In any example the colors can be swapped and remain valid.

Circles =
A. empty list
B. (13, 16, 20)
C. (30, 16, 20)
D. (200, 16, 20)
E. (42, 50, 20)
F. (42, 50, 20), (17, 40, 30)
G. (42, 50, 20), (17, 20, 30)
H. (42, 50, 20), (17, 10, 30), (10, 50, 30)
I. (42, 50, 20), (17, 10, 30), (35, 50, 20)
J. (18, 36, 40), (18, 63, 40), (18, 50, 20)
K. (100, -10, -20), (60, 50, -10)
L. (18, 36, 40), (18, 63, 40), (18, 50, 20), (14, 50, 20), (5, 50, 18), (20, 0, 0), (70, 22, 0), (10000, -9970, 0), (135, 100, -80) 


A.  B.  C.  D. 
E.  F.  G.  H. 
I.  J.  K.  L. 

Make sure your output behaves similar to all these examples.
Mathematica, 165 bytes

ContourPlot[Cos@Tr[Boole[Norm[{x,y}-#2]&lt;#]Pi&amp;@@@#4],{x,0,#},{y,0,#2},PlotPoints-&gt;5!,AspectRatio-&gt;Automatic,Frame-&gt;False,ContourShading-&gt;RGBColor@@@#3,Contours-&gt;{0}]&amp;


Pure function taking four arguments: the width, the height (both integers), an ordered pair of triples of numbers between 0 and 1 (representing the two RGB colors), and a list of items of the form {r, {x, y}} to record the radii and centers of the circles. For example, the first example in the OP would be called with the arguments [300, 200, {{1, 0.784, 0}, {0.5, 0, 1}}, {{25, {50, 80}}, {40, {80, 120}}, {300, {-100, 6}}, {17, {253, 162}}}]. The positive y-axis points upwards in Mathematica.

Norm[{x,y}-#2]&lt;# detects whether a point is inside a given circle; Boole[...]Pi converts that True or False to π or 0. After computing those πs/0s over all the input circles, Tr adds them up and Cos converts even multiples of π to 1, odd multiples of π to –1. ContourPlot[...,Contours-&gt;{0}] then colors the appropriate region of the plane in two colors depending on whether the value is greater or less than 0. AspectRatio-&gt;Automatic makes circles look like circles; PlotPoints-&gt;5! gives a decent accuracy (boost it to 9! if you really want an amazing picture, far in the future!); Frame-&gt;False gets rid of the axes; and ContourShading-&gt;RGBColor@@@#3 uses the input colors for the contours.

Sample output, with the first pair of colors (since they're nice) but the last set of circles: