# Gradient fill on the top surface of an annulus

Is it possible to use a gradient fill on the top surface of this annulus in matematica?

Graphics3D[
ResourceFunction["Annulus3D"][{{0, 0, 0}, {0, 0, 2}}, {1, 3}]
]


I tried to use the Color function option but it doesn't work.

• If you feel that the below answer solves your problem, make sure to accept it (click the checkmark). If not, leave a comment or edit your question to provide additional clarification. Aug 16, 2023 at 22:40

Something like this perhaps? This selects Hue based on angle:

n = 200;
s = Subdivide[n];
gOpts = {EdgeForm[], Hue[#],
ResourceFunction["Annulus3D"][{{0, 0, 0}, {0, 0, 1}}, {1,
3}, {#*2 Pi, (# + 1/n)*2 Pi}]} & /@ Most[s];
Graphics3D[gOpts, Boxed -> False, Lighting -> "Neutral"]



Another version with Hue based on radius:

n = 200;
maxR = 3;
rInner = 1;
s = Subdivide[rInner, maxR, n];
rescaled = Rescale[s];
gOpts = Table[{EdgeForm[], Hue[rescaled[[i]]],
ResourceFunction["Annulus3D"][{{0, 0, 0}, {0, 0, 1}}, {s[[i - 1]],
s[[i]]}]}, {i, 2, n}];
Graphics3D[gOpts, Boxed -> False, Lighting -> "Neutral"]



As pointed out in a comment below, you may only want the top to be colored. I used an example under the styling section of the Annulus3D documentation to just color the top surface (the top, bottom, and inner and outer radius are the first four elements of an Annulus3D object it looks like). This is a pretty ugly implementation so you can likely make it easier to read:

n = 200;
s = Subdivide[n];
gOpts = Flatten[
Table[{baseL, baseH, circumIn, circumOut} =
ResourceFunction["Annulus3D"][{{0, 0, 0}, {0, 0, 1}}, {1,
3}, {i*2 Pi, (i + 1/n)*2 Pi}][[1 ;; 4]];
{{EdgeForm[], Hue[i], baseH}, {EdgeForm[], Black,
baseL}, {EdgeForm[], Black, circumIn}, {EdgeForm[] , Black,
circumOut}}, {i, Most[s]}], 1];
Graphics3D[gOpts, Boxed -> False, Lighting -> "Neutral"]


• @infinitezero thanks for pointing this out. I added another example, though the code for it can probably be improved
– ydd
Aug 14, 2023 at 16:30