A body in thermal equilibrium that absorbs all radiation (a blackbody) emits the Planck spectrum, which depends on its temperature only:
B(λ,T) = 2hc² / [λ⁵ (e^(hc/λkT) − 1)]
λpeak·T = b = 2.897772×10⁻³ m·K (Wien)
M = ∫ πB dλ = σT⁴ (Stefan-Boltzmann)
The classical Rayleigh-Jeans law 2ckT/λ⁴ matches Planck at long wavelengths but diverges at short ones (the "ultraviolet catastrophe"), which is why Planck introduced energy quanta in 1900.
How the colour is computed: the spectrum is weighted by the CIE 1931 colour-matching functions (analytic multi-lobe fit of Wyman, Sloan and Shirley 2013), converted to XYZ and then to linear sRGB, gamut-clipped and normalised. The displayed glow brightness follows the real visible luminance (log-compressed so a 1000 K and a 15000 K body can both be seen).
Simplifications: real stars and metals are not perfect blackbodies (emissivity below 1, spectral lines, limb darkening); the Sun's actual photosphere is close to 5772 K. The peak wavelength depends on whether you plot per unit wavelength or per unit frequency; this page uses per-wavelength radiance. The iron bar is limited to its melting point (1811 K); it first glows visibly near the Draper point (about 800 K).
The star and bar pictures are Blender (Cycles) renders used as grayscale emission masks and tinted with the computed colour.