I want to have a disk. But this disk shouldn't have a fixed color; instead, I'd like it's color to fade smoothly.
Until now, I came up with two ideas how to achieve this.
Idea #1:
smoothlyFadingColorDisk1[r_] :=
DensityPlot[Max[0, r - Sqrt[x^2 + y^2]], {x, -r, r}, {y, -r, r},
ColorFunction -> (Opacity[#, Purple] &)]
Problems:
- It displays axes, and
Axes->False
won't remove them. This is meant to be just a part of a more complex graphics, so the axes are here completely inaproppiate. (blocking problem) - This makes no sense semantically. I want a Disk (a simple image), not a plot.
Idea #2:
smoothlyShiftedColorDisk2[r_, n_] :=
Graphics[Flatten@
Prepend[{Thickness[1/(2*n - 1)]}]@
Table[{Opacity[(n - i + 1)/n, Purple],
Circle[{0, 0}, (i - 1/2)*r/(n - 1/2)]}, {i, 1, n}]]
Problems:
- It looks bad at some values of
n
and horrible at others. This seems to be because for some reason (inaccurate floating point calculations? my mistake in the maths?) the concentric circles are overlapping, and they shouldn't. They should be ideally next to each other. (blocking problem) - I have to manually set the number of colors used (the
n
variable, number of concentric cirlces). And I'd like Mathematica to take care of this for me, as happens in the first example.
So - neither of these two ideas acheves what I am trying to achieve. Er... How to do this properly?
I have a feeling that this should be possible to achieve in a much simpler way than I was trying to do this...