Author of the article here; I wasn't able to understand how to get that to work, and I talked about that in the post. This demo is doing that: https://jlongster.com/why-chromaticity-shape#block-31f373
The problem is "for each pixel inside the area". I could have done that, and then clipped the output by that shape. The problem is this doesn't answer why the shape is this way at all because you are using the shape itself to clip the output. It felt fake.
I do think this is what is most common though. I was trying to understand a more rigorous approach, and the one where you generate spectra and try to fill it is described here: https://clarkvision.com/articles/color-cie-chromaticity-and-...
That feels like a more rigorous approach, but clipping is probably "good enough" too