My goal is to make an iOS-like enable/disable switch like this:
I use a LocatorPane
for the slider with so-called "jumps" to only make two settings possible:
LocatorPane[Dynamic[pt], Graphics[{LightGray, Rectangle[{-.5, -.5}, {1.5, .5}]}],
{{0, 0}, {1, 0}, {1, 1}},
Appearance -> ImageResize[Graphics[{Gray, Disk[]},
Background -> None], Scaled[.25]]]
Now, I want make the 'slider' better looking by adding a gradient to it but i cannot make it work. ColorFunction
(probably the only way to add gradients in Mathematica) seems not available to Disk
.
I tried using Heike's solution for gradients in this question, but pasting the graphics from her function into my code does not work: the size of these graphics is way too large and rescaling it (using ImageResize
) adds a white background which I cannot remove.
I tried making a disk with a gradient myself using Raster
and ImageAdd
, but here the same problem of a none-removable background occurs again:
ImageAdd[
Graphics[Raster[Table[i, {i, 100}, {j, 200}],
{Scaled[{0, 0}], Scaled[{1, 1}]}, {1, 100}, ColorFunction -> "GrayTones"]],
Graphics[Disk[]]]
Can anyone give some tips about how to add gradients to disks?