rgb.py

Created by wperez274

Created on April 22, 2023

3.75 KB


from math import *
from cmath import *
from random import *
from random import randint as R
from kandinsky import *
from ion import *
from time import *

EXIT=False

r=46
g=131
b=176



bg=(r,g,b)


fill_rect(0,0,322,150,bg)
fill_rect(0,150,322,4,(0,0,255))

fill_rect(0,154,322,140,(0,0,0))


while not EXIT:
  
  
  draw_string("Press [EXE] to select color",16,162,'black','cyan')
  draw_string("Press [OK] to Randomize color",12,190,'black',"pink")

  draw_string("rgb: "+str(bg),40,10)



  if keydown(KEY_OK):
    sleep(0.2)
    r=R(0,255)
    g=R(0,255)
    b=R(0,255)
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)

    

  if keydown(KEY_BACKSPACE):
    sleep(0.2)
    r=g=b=0
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)

  if keydown(KEY_TOOLBOX):
    sleep(0.2)
    r=g=b=255
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)


  if keydown(KEY_SHIFT):
    sleep(0.2)
    r+=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)

  if keydown(KEY_EXP):
    sleep(0.2)
    r-=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)


  if keydown(KEY_ALPHA):
    sleep(0.2)
    g+=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)

  if keydown(KEY_LN):
    sleep(0.2)
    g-=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)

  if keydown(KEY_XNT):
    sleep(0.2)
    b+=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)

  if keydown(KEY_LOG):
    sleep(0.2)
    b-=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)




  if keydown(KEY_UP):
    sleep(0.2)
    r+=1
    g+=1
    b+=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)


  if keydown(KEY_DOWN):
    sleep(0.2)
    r-=1
    g-=1
    b-=1
    bg=(r,g,b)
    fill_rect(0,0,322,150,bg)
    draw_string("rgb: "+str(bg),40,10)



  

  if r>254:
    r=255
  if r<1:
    r=0
  if g>254:
    g=255  
  if g<1:
    g=0
  if b>254:
    b=255  
  if b<1:
    b=0

  if r<=63:
    draw_string("Low Red",10,130,(155,0,0),(236, 240, 225))

  if g<=63:
    draw_string("Low Green",105,130,(0,90,0),(116, 252, 18))

  if b<=63:
    draw_string("Low Blue",215,130,(45, 5, 110),(231,235,255))


  if r>=64 and r<=189:
    draw_string("Med Red",10,110,(155,0,0),(236, 240, 225))

  if g>=64 and g<=189:
    draw_string("Med Green",105,110,(0,90,0),(116, 252, 18))

  if b>=64 and b<=189:
    draw_string("Med Blue",215,110,(45, 5, 110),(231,235,255))


  if r>=190:
    draw_string("High Red",10,90,(R(150,255),0,0),"pink")
  if g>=190:
    draw_string("High Green",105,90,(45,R(0,125),25),(213, 245, 122))

  if b>=190:
    draw_string("High Blue",215,90,(0, 0, R(150,255)),"cyan")



  if r-g>=100 and r-b>=100:
    draw_string("          Mostly [Red]             ",0,50,(255,100,100),(0,0,0))

  if g-r>=100 and g-b>=100:
    draw_string("          Mostly [Green]             ",0,50,(100,255,100),(0,0,0))

  if b-r>=100 and b-g>=100:
    draw_string("          Mostly [Blue]             ",0,50,(100,100,255),(0,0,0))


  if r>=230 and g>=230 and b>=230:
    draw_string("          Mostly [White]             ",0,50)

  if r<=50 and g<=50 and b<=50:
    draw_string("          Mostly [Black]             ",0,50,(255,255,255),(0,0,0))



  if keydown(KEY_EXE):    
    EXIT=True


  fill_rect(0,0,322,3,(0,0,0))



fill_rect(0,0,322,222,"white")
fill_rect(0,0,322,100,(0,0,0))


fill_rect(0,100,322,35,bg)

fill_rect(0,180,322,42,bg)


draw_string("PRESS [OK] TO EXIT",40,50,'black','yellow')  

fill_rect(0,135,322,2,(0,0,0))
fill_rect(0,180,322,2,(0,0,0))


draw_string("Color:"+str(bg),40,150)




print(str(bg))

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.