from math import * from random import * from random import randint as R from kandinsky import * from kandinsky import fill_rect as F from ion import * from time import * cursor_x=40 cursor_y=80 RED,GREEN,BLUE=[ R(0,255), R(0,255), R(0,255) ] #border F(0,0,3,222,"black") F(318,0,3,222,"black") F(0,0,322,3,"black") F(0,220,322,2,"black") #line F(0,73,322,4,"black") #top color F(3,3,315,70,(RED,GREEN,BLUE)) #line F(0,140,322,3,"black") #middle color #F(0,78,322,60,"black") while 1: if cursor_y==80: draw_string("Red: "+str(RED),50,80,"black","yellow") else: draw_string("Red: "+str(RED),50,80,(120,0,0)) if cursor_y==100: draw_string("Green: "+str(GREEN),50,100,"black","yellow") else: draw_string("Green: "+str(GREEN),50,100,(0,120,0)) if cursor_y==120: draw_string("Blue: "+str(BLUE),50,120,"black","yellow") else: draw_string("Blue: "+str(BLUE),50,120,(0,0,120)) if keydown(KEY_UP) and cursor_y==80: sleep(0.2) cursor_y=80 if keydown(KEY_UP) and cursor_y==100: sleep(0.2) cursor_y=80 if keydown(KEY_UP) and cursor_y==120: sleep(0.2) cursor_y=100 if keydown(KEY_DOWN) and cursor_y==80: sleep(0.2) cursor_y=100 if keydown(KEY_DOWN) and cursor_y==100: sleep(0.2) cursor_y=120 if keydown(KEY_DOWN) and cursor_y==120: sleep(0.2) cursor_y=120 #randomize if keydown(KEY_OK) and cursor_y==80: RED=R(0,255) F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.2) if keydown(KEY_OK) and cursor_y==100: GREEN=R(0,255) F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.2) if keydown(KEY_OK) and cursor_y==120: BLUE=R(0,255) F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.2) #Decrease value (+) if keydown(KEY_LEFT) and cursor_y==80: RED-=1 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if keydown(KEY_LEFT) and cursor_y==100: GREEN-=1 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if keydown(KEY_LEFT) and cursor_y==120: BLUE-=1 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) #Increase value (-) if keydown(KEY_RIGHT) and cursor_y==80: RED+=1 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if keydown(KEY_RIGHT) and cursor_y==100: GREEN+=1 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if keydown(KEY_RIGHT) and cursor_y==120: BLUE+=1 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if RED<0:RED=0 if GREEN<0:GREEN=0 if BLUE<0:BLUE=0 if RED>255:RED=255 if GREEN>255:GREEN=255 if BLUE>255:BLUE=255 #reset value to 0 if keydown(KEY_BACKSPACE) and cursor_y==80: RED=0 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if keydown(KEY_BACKSPACE) and cursor_y==100: GREEN=0 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) if keydown(KEY_BACKSPACE) and cursor_y==120: BLUE=0 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,cursor_y,315,20,"white") sleep(0.15) #display info on screen # draw_string("R,G,B = "+"("+str(RED)+","+str(GREEN)+","+str(BLUE)+")",3,3) draw_string("keys: [Left/Right] = -/+ Value",9,145,"black",(19,219,246)) draw_string("keys: [Up/Down] = Select",9,165,"black",(214,177,9)) draw_string("[OK],[Toolbox]=Random,RandomAll",5,185,"black",(0,253,207)) draw_string("key Backspace] = Reset",9,205,"black",(235,235,235)) if keydown(KEY_TOOLBOX): RED=R(0,255) GREEN=R(0,255) BLUE=R(0,255) F(3,3,315,70,(RED,GREEN,BLUE)) F(3,80,315,60,"white") sleep(0.2) if keydown(KEY_VAR): BLUE=GREEN=BLUE=0 F(3,3,315,70,(RED,GREEN,BLUE)) F(3,80,315,60,"white") sleep(0.2)