<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="http://www.w3.org/TR/REC-html40"> <head> <title>Spectrum</title> <style> #spectrum {position: absolute; top: 10; left: 10;} v\:* {behavior:url(#default#VML);} </style> <script type="text/javascript"> <!-- // Converts a number from 0 to 255 into a two digit hex number function bytehex(n) { var a = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"); var msn=Math.floor(n/16); var lsn=n%16; return a[msn]+a[lsn]; } //--> </script> </head> <body bgcolor="black"> <!-- Draw the spectrum --> <div id="spectrum"> <script type="text/javascript"> <!-- function selSpec() { var d = parent.select.document.spectrum; var continuum = true; var lines = true; //Initialization var m; if (d.res[0].checked) m = d.res[0].value; else m = d.res[1].value; var gamma = 0.8; var spec; for (var i=0; i<d.spec.length; i++) if (d.spec[i].checked) spec=d.spec[i].value; var width2 = new Array(); if (spec == "h_absorption") { // H lines in absorption var line = new Array(383.5,388.9,397.0,410.2,434.0,486.1,656.3); var width = new Array( 5, 5, 5, 5, 5, 5, 5); var strength = new Array( 0.05, 0.075,0.1, 0.3, 0.5, 0.5, 0.5); } else if (spec == "h_emission") { // H lines in emission var line = new Array(383.5,388.9,397.0,410.2,434.0,486.1,656.3); var width = new Array( 2, 2, 2, 2, 2, 2, 2); var strength = new Array( 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0); continuum = false; } else if (spec == "he_emission") { // He lines in emission var line = new Array(402.6,438.8,447.1,471.3,492.2,501.6,587.6,667.8,706.5,728.1); var width = new Array( 2, 2, 2, 2, 2, 2, 3, 2, 2, 2); var strength = new Array( 0.6, 0.3, 0.75, 0.4, 0.5, 0.75, 1.0, 0.75, 0.6, 0.3); continuum = false; } else if (spec == "li_emission") { // Li lines in emission var line = new Array(391.5,413.3,427.3,427.3,460.3,497.2,610.3,670.8); var width = new Array( 1, 2, 1, 1, 2, 1, 3, 2); var strength = new Array( 0.1, 0.5, 0.1, 0.1, 0.5, 0.2, 1.0, 0.8); continuum = false; } else if (spec == "na_emission") { // Na lines in emission var line = new Array(432.5,439.3,449.4,449.8,466.5,466.9,497.9,498.3,515.3,568.3,568.8,589.0,589.6,615.4,616.1); var width = new Array( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1); var strength = new Array( 0.1, 0.1, 0.1, 0.2, 0.2, 0.25, 0.3, 0.4, 0.1, 0.3, 0.5, 1.0, 0.9, 0.2, 0.3); continuum = false; } else if (spec == "k_emission") { // K lines in emission var line = new Array(404.4,534.9,536.0,578.2,580.2,583.2,691.1,693.9,760.4,762.7,766.5,769.9); var width = new Array( 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 3, 3); var strength = new Array( 0.05, 0.05, 0.05, 0.05, 0.1, 0.05, 0.3, 0.7, 0.1, 0.05, 1.0, 0.9); continuum = false; } else // Continuum only with no lines lines = false; if (lines) { // Precompute square of line widths for (j=0; j<width.length; j++) width2[j]=width[j]*width[j]; } // Start loop to calculate spectrum for (i=0; i<=m; i++) { var r=g=b=0.0; var w=380.0+i*400.0/m; var t=0.0; if (lines) { for (j=0; j<line.length; j++) { offset=Math.abs(w-line[j]); if (offset < 8*width[j]) t+=strength[j]*width2[j]/(4.0*offset*offset+width2[j]); } } if (continuum || t > 0) { t=Math.min(t,1.0); if (w <= 440.0) { // Violet shading to blue r=-1.0*(w-440.0)/60.0; b=1.0; } else if (w <= 490.0) { // Blue shading to cyan g=(w-440.0)/50.0; b=1.0; } else if (w <= 510.0) { // Cyan shading to green g=1.0; b=-1.0*(w-510.0)/20.0; } else if (w <= 580.0) { // Green shading to yellow r=(w-510.0)/70.0 g=1.0; } else if (w <= 645.0) { // Yellow shading to red r=1.0; g=-1.0*(w-645)/65.0; } else if (w <= 780.0) // Constant red r=1.0; if (w > 700.0) // Fade out at the violet end s=0.3+0.7*(780-w)/80.0; else if (w < 420) // Fade out at the red end s=0.3+0.7*(w-380)/40.0; else // Constant intensity in the middle s=1.0; // Calculate apparent strength and RGB values if (continuum) s=Math.max(s-t,0.0) else s*=t; var ir=Math.floor(255*Math.pow(s*r,gamma)); var ig=Math.floor(255*Math.pow(s*g,gamma)); var ib=Math.floor(255*Math.pow(s*b,gamma)); // Convert the RGB values to Hex codes and draw a colored line var ss="#"+bytehex(ir)+bytehex(ig)+bytehex(ib); document.write("<v:line from='"+i+",0' to='"+i+",100' strokecolor="+ss+"></v:line>"); } // Draw white tick marks to indicate wavelength if (w%10 == 0) { if (w%100 == 0) { // Big ones at 100 nm intervals document.write("<v:line from='"+i+",0' to='"+i+",15' strokecolor='white'></v:line>"); document.write("<v:line from='"+i+",85' to='"+i+",100' strokecolor='white'></v:line>"); } else if ((w+50)%100 == 0) { // Medium sized one at half 100 intervals document.write("<v:line from='"+i+",0' to='"+i+",10' strokecolor='white'></v:line>"); document.write("<v:line from='"+i+",90' to='"+i+",100' strokecolor='white'></v:line>"); } else { // Small one at 10 nm intervals document.write("<v:line from='"+i+",0' to='"+i+",5' strokecolor='white'></v:line>"); document.write("<v:line from='"+i+",95' to='"+i+",100' strokecolor='white'></v:line>"); } } } } selSpec(); //--> </script> </div> </body> </html>