color decoder
from math import * from kandinsky import * from kandinsky import fill_rect as FILL from kandinsky import draw_string as STR from ion import * from ion import keydown as GKEY from time import * from random import * from random import randint as RINT def refreshData(): FILL(1,123,85,95,'white') CALC_ON=True R=RINT(0,255) G=RINT(0,255) B=RINT(0,255) R_2=RINT(0,255) G_2=RINT(0,255) B_2=RINT(0,255) selector_x = 5 selector_y = 129 t=0.2 FILL(92,120,322-92,222-120,(0,0,0)) FILL(0,2,322,118,(R,G,B)) R_COPY_1=None G_COPY_1=None B_COPY_1=None while CALC_ON: if GKEY(KEY_RIGHT) and selector_y==129: sleep(t) R+=1 FILL(40,124,40,18,"white") if GKEY(KEY_LEFT) and selector_y==129: sleep(t) R-=1 FILL(40,124,40,18,"white") if GKEY(KEY_RIGHT) and selector_y==147: sleep(t) G+=1 FILL(40,142,40,18,"white") if GKEY(KEY_LEFT) and selector_y==147: sleep(t) G-=1 FILL(40,142,40,18,"white") if GKEY(KEY_RIGHT) and selector_y==165: sleep(t) B+=1 FILL(40,160,40,18,"white") if GKEY(KEY_LEFT) and selector_y==165: sleep(t) 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 GKEY(KEY_DOWN) and selector_y==129: selector_y=147 FILL(selector_x,124,12,12,"white") sleep(t) if GKEY(KEY_DOWN) and selector_y==147: selector_y=165 FILL(selector_x,147,12,12,"white") sleep(t) if GKEY(KEY_DOWN) and selector_y==165: selector_y=183 FILL(selector_x,165,12,12,"white") sleep(t) if GKEY(KEY_UP) and selector_y==183: selector_y=165 FILL(selector_x,178,12,12,"white") sleep(t) if GKEY(KEY_UP) and selector_y==165: selector_y=147 FILL(selector_x,160,12,12,"white") sleep(t) if GKEY(KEY_UP) and selector_y==147: selector_y=129 FILL(selector_x,142,12,12,"white") sleep(t) # single random R,G,B values if GKEY(KEY_OK) and selector_y==129: sleep(t) R=RINT(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 GKEY(KEY_OK) and selector_y==147: sleep(t) G=RINT(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 GKEY(KEY_OK) and selector_y==165: sleep(t) B=RINT(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 GKEY(KEY_OK) and selector_y==183: sleep(t) R=RINT(0,255) G=RINT(0,255) B=RINT(0,255) FILL(0,2,322,118,(R,G,B)) refreshData() STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) #************************************************ #backspace resets value to zero if GKEY(KEY_BACKSPACE) and selector_y==129: sleep(t) FILL(38,125,32,50,"white") R=0 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_TOOLBOX) and selector_y==129: sleep(t) FILL(38,125,32,50,"white") R=255 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_BACKSPACE) and selector_y==147: sleep(t) FILL(38,125,32,50,"white") G=0 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_TOOLBOX) and selector_y==147: sleep(t) FILL(38,125,32,50,"white") G=255 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_BACKSPACE) and selector_y==165: sleep(t) FILL(38,125,32,50,"white") B=0 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_TOOLBOX) and selector_y==165: sleep(t) FILL(38,125,32,50,"white") B=255 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_BACKSPACE) and selector_y==183: sleep(t) FILL(38,125,32,50,"white") R=G=B=0 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(R,G,B)) if GKEY(KEY_TOOLBOX) and selector_y==183: sleep(t) FILL(38,125,32,50,"white") R=G=B=255 FILL(0,2,322,118,(R,G,B)) STR("Numworks",50,50,"black",(R,G,B)) STR("Calculator!",150,50,"white",(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,(0,90,0),"white") STR("B:"+str(B),18,160,"blue","white") STR("Random",18,178,"black","cyan") STR("all.",18,196,"black","cyan") STR("RED="+str(R),3,3,(100,0,0),(224, 205, 240)) STR("GREEN="+str(G),110,3,(0,80,0),(188, 251, 120)) STR("BLUE="+str(B),230,3,(0,0,100),(200,220,255)) STR("Press [EXE] to Select Color",20,95,'black',(241,235,236)) if GKEY(KEY_EXE): CALC_ON=False FILL(0,0,322,222,(255,255,255)) draw_string("press [OK] to exit",60,180,'black','yellow') mycolor=(R,G,B) FILL(0,68,322,2,(0,0,0)) FILL(0,70,322,80,mycolor) FILL(0,67,322,3,'blue') FILL(0,148,322,3,'blue') STR(str(mycolor),80,100) print(mycolor)