npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

p5.platonic

v0.5.0

Published

A p5.js addon for rendering Platonic solids using WebGL.

Readme

p5.platonic

npm version Lint

A p5.js library for rendering Platonic solids in WEBGL.

Platonic solids.


Usage

solid(args)

Where solid can be one of the following functions:

  • tetrahedron
  • hexahedron (or cube)
  • octahedron
  • dodecahedron
  • icosahedron

Arguments (all optional, any order)

  • length: Number — Edge length (default: 100).
  • center: p5.Vector — Center position (default: origin).
  • colors: Array of colors (either p5.Color or string).
  • fuse: Boolean — Whether to fuse vertex colors across faces (default: false).

Example (Immediate Mode)

function draw() {
  dodecahedron(50, ['yellow', 'blue', 'red'])
}

Retained Mode

Option 1: platonicGeometry (Recommended)

let geom

function setup() {
  createCanvas(400, 400, WEBGL)
  geom = platonicGeometry(dodecahedron, 50, ['yellow', 'blue', 'red'])
}
function draw() {
  background(0)
  orbitControl()
  model(geom)
}

Option 2: buildGeometry

let geom

function setup() {
  createCanvas(400, 400, WEBGL)
  geom = buildGeometry(() => {
    dodecahedron(50, ['yellow', 'blue', 'red'])
  })
  geom.clearColors()
  geom.computeNormals()
}
function draw() {
  background(0)
  orbitControl()
  model(geom)
}

ESM Example (Vite)

Install:

npm install p5 p5.platonic

Then in main.js:

import p5 from 'p5'
import 'p5.platonic'

// Retained mode
let dodecahedronGeom, icosahedronGeom

new p5(p => {
  p.setup = () => {
    p.createCanvas(400, 400, p.WEBGL)
    dodecahedronGeom = p.platonicGeometry(p.dodecahedron, 50, true, ['yellow', 'blue', 'red'], true)
    icosahedronGeom = p.buildGeometry(() => {
      p.icosahedron(50, ['yellow', 'blue', 'red'])
    })
    // icosahedronGeom.clearColors() // optional
    icosahedronGeom.computeNormals() // optional
  }

  p.draw = () => {
    p.background(255)
    p.orbitControl()
    // Retained mode rendering
    p.model(dodecahedronGeom)
    p.push()
    p.translate(-p.width / 4, -p.height / 4, 0)
    p.rotateZ(p.frameCount * 0.01)
    p.rotateX(p.frameCount * 0.01)
    p.rotateY(p.frameCount * 0.01)
    p.model(icosahedronGeom)
    p.pop()
    // Immediate mode rendering
    p.push()
    p.translate(-p.width / 4, +p.height / 4, 0)
    p.rotateZ(p.frameCount * 0.01)
    p.rotateX(p.frameCount * 0.01)
    p.rotateY(p.frameCount * 0.01)
    p.fill('DarkTurquoise')
    p.tetrahedron()
    p.pop()
  }
})

Installation (IIFE / CDN)

Include after p5.js:

<script src="https://cdn.jsdelivr.net/npm/p5.platonic/dist/p5.platonic.js"></script>
<!-- or minified -->
<script src="https://cdn.jsdelivr.net/npm/p5.platonic/dist/p5.platonic.min.js"></script>

Development (VS Code / Gitpod / Codium)

git clone https://github.com/VisualComputing/p5.platonic
cd p5.platonic
npm install

Then open in VS Code, Gitpod, or Codium.

Useful References