When Graphics is used, necessarily the objects come in order. This affects which ones obscure others. When Opacity is not 1, it also affects the color. I would like the color of overlaps to depend only on the colors of the objects and their opacities and not on the order. Can this be done? For example, this simple code illustrates the problem:
Graphics[{Opacity[.5],
Inner[{#1, #2} &, {Red, Blue, Red}, {Disk[{0, 0}, 1],
Disk[{1, 0}, 1], Disk[{2, 0}, 1]}, List]}]
The result is this:
Further info in response to the wonderful answers received so far: I will use this in Manipulate with the disks (or perhaps rectangles) moving around at random. There will also be many of them, such as 1000. So time is important and thus using all permutations is out of consideration (for this particular application).
I have now tested the suggestions. Unfortunately, rasterizing and computing with that takes much too long. If I sort, then that will not give what I want either. So no answer seems to work, sadly.
In response to @Mr.Wizard, here is my example. It is not minimal, but you will want to experiment with various things, I think. In the end, it is not too bad; I used Opacity[0.1] to handle my aesthetic complaint.
Manipulate[
If[startover == "start over",
current = PadRight[{}, nmparticles, {{-torus/2, 0}, {torus/2, 0}}];
startover = False];
While[run, Pause[1/rate];
If[Length[current] == nmparticles,
current =
Clip[current +
RandomVariate[
NormalDistribution[0, 1], {nmparticles, 2}], {-torus, torus}],
current =
PadRight[current, nmparticles, {{-torus/2, 0}, {torus/2, 0}}]]];
Dynamic@Show[
Graphics[{Opacity[.1],
Transpose[{Table[If[OddQ[i], Red, Blue], {i, Length[current]}],
Disk[#, 1] & /@ current}]},
PlotRange -> {{-torus, torus}, {-torus, torus}},
ImageSize -> {475, 475}]],
Style[" Diffusion",
Large], Delimiter, {{run, False, "run"}, {True,
False}}, {{nmparticles, 2, "number of particles"}, 1, 5000, 1,
Appearance -> "Labeled"},
{{rate, 10, "rate"}, 3, 1000, 1,
Appearance -> "Labeled"}, {{torus, 20, "half-size of box"}, 3, 100,
1, Appearance -> "Labeled"}, {{startover, False,
""}, {"start over"}, ControlType -> Setter, Background -> LightRed},
ControlPlacement -> Right,
Initialization :> (current = {{-torus/2, 0}, {torus/2, 0}})]