Rgb
One of the main modes of color representation in computer graphics is RGB mode - a mixture of red, green and blue. To set a color, you need to assign three variables R, G, B values from 0 to 255. Thus, you can get the color of any shade, any brightness.
Representation of some colors in RGB mode
• (255,0,0)

• (0,255,0)

• (255,255,0)

• (0,0,255)

• (0,255,255)

• (255,0,255)

Physical color representation
Light is an e / m wave with a wavelength interval: 380-760 nm.
In the article we will use the representation of light using the wavelength.
From physical observations it is known that red color lies in the range of wavelengths (610; 760), orange - (590; 610), yellow - (570; 590), green - (540; 570), blue - (510; 540) , blue - (480; 510), purple - (380; 480) nm.
If you look at the continuous spectrum of visible radiation, then you can select certain colors on it, between which there is a smooth transition.
')

Therefore, in our method, using the experimental data, we determine in which of the color intervals the input wavelength is located, and then, using the obtained empirical relation, it can be transferred to the RGB mode.
Consider converting the wavelength to RGB for green. We know that the green color lies in the interval (540; 570). Suppose the true green color falls on the wavelength lying in the center of this interval: 555 nm. Therefore, at a given wavelength in RGB mode, it will look like this (0.255.0). As the wavelength increases, the green color gradually turns yellow (255,255.0). On the border of these two colors approximately at a wavelength of 570 nm RGB representation will have the form (127,255,0). For this interval, you can write the formula for the transition from wavelength to the number of red, green, blue in RGB mode.
Analyzing the boundaries of the specified interval of wavelengths, it can be noted that the blue component is not present in it, so you can immediately write: B = 0 You can also see that the green component G = 255 does not change. But for the red component, we write R = [127.5 * (lamda-555) / (570-555)], where [] is the operation of extracting the whole part. The expression is not simplified to preserve the meaning of building dependencies.
When the wavelength falls into the interval (540.555), the green color gradually turns into blue.
On the left border of this interval, the color in the RGB mode is: (0,255,127). Comparing the left (0,255,127) and right (0,255,0) border of the interval, we have R = 0, G = 255
And the amount of the blue component (B) decreases from 127 to 0. The transition can be made using the following formula: R = [127.5 * (1- (lamda-540) / (555-540))]
Using the principle described above, it is possible to obtain transition formulas for all intervals of the spectrum, and implement them as functions for each component.
Implementation
function Red(l:integer):byte; var n:byte; begin if (l>560)and(l<=760) then n:=255; if (l>495)and(l<=555) then n:=0; if (l>570)and(l<=580) then n:=round(127.5+127.5*(l-570)/10); if (l>555)and(l<=570) then n:=round(127.5*(l-555)/15); if (l>480)and(l<=495) then n:=round(127.5-127.5*(l-480)/15); if (l>380)and(l<=480) then n:=round(255-127.5*(l-380)/100); Red:=n; end; function Blue(l:integer):byte; var n:byte; begin if (l>380)and(l<=525) then n:=255; if (l>555)and(l<=760) then n:=0; if (l>540)and(l<=555) then n:=round(127.5-127.5*(l-540)/15); if (l>525)and(l<=540) then n:=round(255-127.5*(l-525)/15); Blue:=n; end; function Green(l:integer):byte; var n:byte; begin if (l>525)and(l<=580) then n:=255; if (l>380)and(l<=495) then n:=0; if (l>610)and(l<=760) then n:=round(63.5-63.5*(l-610)/150); if (l>600)and(l<=610) then n:=round(127.5-63.5*(l-600)/10); if (l>590)and(l<=600) then n:=round(190.5-63.5*(l-590)/10); if (l>580)and(l<=590) then n:=round(255-63.5*(l-580)/10); if (l>495)and(l<=510) then n:=round(127.5*(l-495)/15); if (l>510)and(l<=525) then n:=round(127.5+127.5*(l-510)/15); Green:=n; end; procedure TForm1.FormDblClick(Sender: TObject); var n,k:integer; begin for k:=20 to 360 do for n:=760 to 1520 do form1.Canvas.pixels[n-760,k]:= RGB(Red(round(n/2)),Green(round(n/2)),Blue(round(n/2))); end; ...
The results are shown below:

Applying certain conditions to the construction, one can obtain the emission spectrum of a hydrogen atom:
