Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like the way you're displaying this.

How did you decide on the coordinates for each block of color? KNN on a traditional color wheel?



It is a Voronoi diagram (https://mathworld.wolfram.com/VoronoiDiagram.html) where each point is a web color as it would be positioned on a full hue-saturation color wheel.


It's cheating a bit and using `saturation + brightness / 5` as radius. This separates colors with the same saturation and hue, in particular grays.

    // Based on https://stackoverflow.com/a/54522007/91238 .
    // I've tweaked it to spread out some of the colors (especially they greys)
    // that don't fit well into a true H/S wheel.
    let colorRadius = (s + v/5)*0.75 * radius;
    let colorAngle = h/360 * 2 * Math.PI;




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: