color_theme_generator.py

Created by wperez274

Created on January 12, 2022

4.88 KB


from math import *
from kandinsky import *
from kandinsky import fill_rect as FILL
from kandinsky import draw_string as STR

from ion import *
from time import *
from random import *

R=randint(0,255)
G=randint(0,255)
B=randint(0,255)

R_2=randint(0,255)
G_2=randint(0,255)
B_2=randint(0,255)

RGB=(R_2,G_2,B_2)

selector_x = 5
selector_y = 129
FILL(92,120,322-92,222-120,"grey")
FILL(0,2,322,118,(R,G,B))
    
while 1:
      
  if keydown(KEY_RIGHT) and selector_y==129:
    sleep(0.2)
    R+=1
    FILL(40,124,40,18,"white")
  if keydown(KEY_LEFT) and selector_y==129:
    sleep(0.2)
    R-=1
    FILL(40,124,40,18,"white")
  if keydown(KEY_RIGHT) and selector_y==147:
    sleep(0.2)
    G+=1
    FILL(40,142,40,18,"white")
  if keydown(KEY_LEFT) and selector_y==147:
    sleep(0.2)
    G-=1
    FILL(40,142,40,18,"white")
  if keydown(KEY_RIGHT) and selector_y==165:
    sleep(0.2)
    B+=1
    FILL(40,160,40,18,"white")
  if keydown(KEY_LEFT) and selector_y==165:
    sleep(0.2)
    B-=1
    FILL(40,160,40,18,"white")
  if R>255:
    R=255
  if R<0:
    R=0
  if G>255:
    G=255
  if G<0:
    G=0
  if B>255:
    B=255
  if B<0:
    B=0
  if keydown(KEY_DOWN) and selector_y==129:
    selector_y=147
    FILL(selector_x,124,12,12,"white")
    sleep(0.2)
  if keydown(KEY_DOWN) and selector_y==147:
    selector_y=165
    FILL(selector_x,147,12,12,"white")
    sleep(0.2)
  if keydown(KEY_DOWN) and selector_y==165:
    selector_y=183
    FILL(selector_x,165,12,12,"white")
    sleep(0.2)
  if keydown(KEY_UP) and selector_y==183:
    selector_y=165
    FILL(selector_x,178,12,12,"white")
    sleep(0.2)
  if keydown(KEY_UP) and selector_y==165:
    selector_y=147
    FILL(selector_x,160,12,12,"white")
    sleep(0.2)
  if keydown(KEY_UP) and selector_y==147:
    selector_y=129
    FILL(selector_x,142,12,12,"white")
    sleep(0.2)

# single random R,G,B values   
  if keydown(KEY_OK) and selector_y==129 or keydown(KEY_EXE) and selector_y==129:
    sleep(0.15)
    R=randint(0,255)
    FILL(0,2,322,118,(R,G,B))
    FILL(38,125,32,50,"white")
    STR("Numworks",50,50,"black",(R,G,B))
    STR("Calculator!",150,50,"white",(R,G,B))
  
  if keydown(KEY_OK) and selector_y==147 or keydown(KEY_EXE) and selector_y==147:
    sleep(0.15)
    G=randint(0,255)
    FILL(0,2,322,118,(R,G,B))
    FILL(38,125,32,50,"white")
    STR("Numworks",50,50,"black",(R,G,B))
    STR("Calculator!",150,50,"white",(R,G,B))
  
  if keydown(KEY_OK) and selector_y==165 or keydown(KEY_EXE) and selector_y==165:
    sleep(0.15)
    B=randint(0,255)
    FILL(0,2,322,118,(R,G,B))
    FILL(38,125,32,50,"white")
    STR("Numworks",50,50,"black",(R,G,B))
    STR("Calculator!",150,50,"white",(R,G,B))
  
  if keydown(KEY_OK) and selector_y==183 or keydown(KEY_EXE) and selector_y==183:
    sleep(0.15)
    R=randint(0,255)
    G=randint(0,255)
    B=randint(0,255)
    R_2=randint(0,255)
    G_2=randint(0,255)
    B_2=randint(0,255)
    RGB=(R_2,G_2,B_2)
    FILL(0,2,322,118,(R,G,B))    
    STR("Font (R,G,B) :"+str(RGB),20,10,(R_2,G_2,B_2),(R,G,B))
    STR("Numworks",50,50,"black",(R,G,B))
    STR("Calculator!",150,50,"white",(R,G,B))

#backspace resets value
#to zero  
  if keydown(KEY_BACKSPACE) and selector_y==129:
    sleep(0.15)
    FILL(38,125,32,50,"white")
    R=0
    R_2=255
    RGB=(R_2,G_2,B_2)
    FILL(0,2,322,118,(R,G,B))    
    STR("Font (R,G,B) :"+str(RGB),20,10,(R_2,G_2,B_2),(R,G,B))
 
  if keydown(KEY_BACKSPACE) and selector_y==147:
    sleep(0.15)
    FILL(38,125,32,50,"white")
    G=0
    G_2=255
    RGB=(R_2,G_2,B_2)
    FILL(0,2,322,118,(R,G,B))    
    STR("Font (R,G,B) :"+str(RGB),20,10,(R_2,G_2,B_2),(R,G,B))

  if keydown(KEY_BACKSPACE) and selector_y==165:
    sleep(0.15)
    FILL(38,125,32,50,"white")
    B=0
    B_2=255
    RGB=(R_2,G_2,B_2)
    FILL(0,2,322,118,(R,G,B))    
    STR("Font (R,G,B) :"+str(RGB),20,10,(R_2,G_2,B_2),(R,G,B))
 
    
  if keydown(KEY_BACKSPACE) and selector_y==183:
    sleep(0.15)
    FILL(38,125,32,50,"white")
    R,G,B = 0,0,0
    
    R_2=randint(50,255)
    G_2=randint(50,255)
    B_2=randint(50,255)
    
    RGB=(R_2,G_2,B_2)
    FILL(0,2,322,118,(R,G,B))    
   
    

  FILL(selector_x,selector_y,6,6,"black")
  FILL(0,120,322,2,"black")
  FILL(0,0,322,2,"black")
  FILL(90,122,2,100,"black")
  STR("(OK)  = Randomize",95,125,(255,255,255),(0,0,50))
  STR("Left  = Decrease Value",97,143,(255,255,255),(0,0,100))
  STR("Right = Increase Value",97,161,(255,255,255),(0,0,150))
  STR("Up/Down= Selector Move",97,179,(255,255,255),(0,0,200))
  STR("Backspace = Reset to 0",97,197,(255,255,255),(100,0,255))
  STR("R:"+str(R),18,124,"red","white")
  STR("G:"+str(G),18,142,"green","white")
  STR("B:"+str(B),18,160,"blue","white")
  STR("Random",18,178,"black","cyan")
  STR("all.",18,196,"black","cyan")
  STR("Numworks",50,50,"orange",(R,G,B))
  STR("Calculator!",150,50,"white",(R,G,B))
  STR("By: Wilson",100,90,(R,G,B),(R_2,G_2,B_2))
  STR("Font (R,G,B) :"+str(RGB),20,10,(R_2,G_2,B_2),(R,G,B))

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.