5
$\begingroup$

What is the simplest method for coloring each polygon face of a polyhedron with a specified color? For instance suppose I have a list of $12$ colors ({ Red, Green, ... }) I would like to apply to the different faces of a PolyhedronData["Dodecahedron"] in some assigned order and keep the entity as a Dodecahedron.

$\endgroup$
6
$\begingroup$
faces = First@Normal@PolyhedronData["Dodecahedron", "Faces"];
colors = Table[ColorData[97, i], {i, 12}];
Graphics3D@Riffle[colors, faces]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Yep... short and sweet. Thanks. ($\checkmark$) $\endgroup$ – David G. Stork Aug 19 at 21:45
7
$\begingroup$

You can get the polygons directly using the property "Polygons":

polygons = PolyhedronData["Dodecahedron", "Polygons"];
colors = ColorData[97]/@Range[12];

Graphics3D[Transpose[{colors, polygons}]]

enter image description here

$\endgroup$
2
$\begingroup$

This works, but could be improved:

myVertices = N@PolyhedronData["Dodecahedron", "Vertices"];
myFaceIndices = PolyhedronData["Dodecahedron", "Faces"];
mycolors = {Red, Orange, Yellow, Green, Blue, Orange, Black, White, 
   Purple, Green, Red, Yellow};
Graphics3D@
 Transpose[{mycolors, (Polygon[myVertices[[#]]] & /@ myFaceIndices)}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.