A star, or a planet, emits electromagnetic radiation made up of a continuous spectrum (black body) which depends on its temperature, emission, and absorption rays which depend on the matter located between the object and the telescope.
A black body strongly interacts with the radiation that it emits, it is "opaque". It absorbs all the energy it receives, and emits a radiation that depends on its temperature, in all wavelengths. The warmer it is, the more its light is shifted to the short wavelengths.
The Wien law gives the wavelength of the emission maximum :
. It enables us to define a relationship between temperature and color, via the correspondence between wavelength and color.
For instance, the human body is at 37° Celsius, i.e. 310 K. lambda max = meters. The human body emits radiation in the infrared.
The Sun has a temperature of 5780 K. Its emission is strong in the visible wavelengths. Probably the human eye adapted to "see" the region of the electromagnetic spectrum where the radiation of the Sun is the strongest.
The temperature of a body T corresponds to a thermal disturbance velocity given by :
where m is the mass and k the Boltzmann constant.
That's the reason why, if a planet is too warm, the molecules of its atmosphere have a sufficient velocity to escape from the planet. For instance, that's the reason why, in the atmosphere of the Earth, there is oxygen but no helium.
The Stefan-Boltzmann law gives the total emitted flux :