Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download

Plotting a face-coloured dodecahedron.

Project: KOB1
Views: 33
Image: ubuntu1804
# coloring the faces of a dodecahedron from random import shuffle r = 'red' g = 'green' b = 'blue' colors = [r,g,b,r,g,b,r,g,b,r,g,b] # specify your color distribution here, 12 colours needed shuffle(colors) D = dodecahedron() F = D.faces() G = Graphics() for f,c in zip(F,colors): G += polygon3d(f, color=c, opacity=1) for e in D.edges(): G +=line3d(e, color='black', thickness=5) print(colors) G.show(frame=False)
['blue', 'blue', 'red', 'red', 'green', 'green', 'red', 'blue', 'red', 'green', 'blue', 'green']
3D rendering not yet implemented
# coloring the vertices of a cube from random import shuffle r = 'red' g = 'green' b = 'blue' colors = [r,r,r,r,g,b,b,g] # specify your color distribution here, 8 colours needed #shuffle(colors) D = cube() V = D.vertices() G = Graphics() for f,c in zip(V,colors): G += point3d(f, color=c, size=30) for e in D.edges(): G +=line3d(e, color='black', thickness=5) print(colors) G.show(frame=False)
['red', 'red', 'red', 'red', 'green', 'blue', 'blue', 'green']
3D rendering not yet implemented