spectrum.py

Created by parisseb

Created on February 06, 2020

674 Bytes

Spectre visible. Script adapté de https://workshop.numworks.com/python/uncurieux/visible_spectrum Nécessite KhiCAS.


def spectrum():
  r=255
  g=0
  b=255
  for i in range(320):
    if i<54:
        r=r-int(255/53)
    elif i>85 and i<102:
        g=g+int(255/16)
    elif i>101 and i<123:
        b=b-int(255/21)
    elif i>170 and i<194:
        r=r+int(255/30)
    elif i>194 and i<235:
        g=g-int(255/43)
        r=255
    elif i>233:
        g=0
    fill_rect(i,0,1,100,rgb(r,g,b)) 
  m=-1
  draw_string("nm",190,85)
  for n in range(10):
   l=int(input("l (400,700): "))
   if l<=0:
     break
   if m>=0:
     cm=int(((m-400)*320)/300)
     fill_rect(cm,50,1,50,65535)
   cm=int(((l-400)*320)/300)
   fill_rect(cm,50,1,50,0)
   draw_string(str(l),150,85)
   m=l

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.