DEV Community

Cover image for I built an open-source diamond size visualizer (to-scale, faceted SVG)
CDEV
CDEV

Posted on

I built an open-source diamond size visualizer (to-scale, faceted SVG)

Ever wondered how big a "1 carat diamond" actually is? It's pure geometry

  • so I built a free, open-source tool that draws any diamond to true scale.

Live demo: https://diamondguide.co.za/diamond-size-calculator
Repo (MIT): https://github.com/etchad2-hub/diamond-size-calculator

The problem

Carat is a measure of weight, not size. So "1 carat" tells a shopper
nothing about what the stone actually looks like on a hand. I wanted a
tool that renders the real millimetre size, for any shape, at actual scale
on screen.

The fun part: size is a cube root

A diamond is 3D, so its weight scales with volume — meaning the linear
size scales with the cube root of carat weight:

const dimAt = (base1ct, carat) => base1ct * Math.cbrt(carat);
// round brilliant: 6.5mm at 1ct -> 8.2mm at 2ct (only ~26% wider!)

That's why doubling the carats barely widens the stone but massively
raises the price.

Faceting with SVG

Each gem is a little facet-tessellation engine: sample the girdle outline
into points, scale it into concentric rings (girdle → mid → table).

Top comments (0)