rgb_hue.py

Created by ziii

Created on February 20, 2022

969 Bytes

A basic program to help you see what rgb values make what color.

How to use :

The upper part of the screen shows the color of the rgb values

The number with next to it a plus and a minus is the number you’ll add to the rgb values.

Key 4 adds to the red value.

Key 5 adds to the green value.

Key 6 adds to the blue value.

Key 1 substracts to the red value.

Key 2 substracts to the green value.

Key 3 substracts to the blue value.


from kandinsky import *
from ion import *
from time import *
rgb=[0,0,0]
add=10
change=1
fill_rect(0,0,320,150,color(rgb[0],rgb[1],rgb[2]))
draw_string("4-6 adds",160,160)
draw_string("1-3 substracts",160,180)
while 1:
  if change:
    for x in range(3):
      if rgb[x]<0:
        rgb[x]=0
      elif rgb[x]>255:
        rgb[x]=255
    fill_rect(0,160,160,18,color(255,255,255))
    draw_string("+ {} -".format(str(add)),0,160)
    fill_rect(0,180,160,18,color(255,255,255))
    draw_string(str(rgb),0,180)
    fill_rect(0,0,320,150,color(rgb[0],rgb[1],rgb[2]))
    sleep(0.1)
  change=1
  if keydown(KEY_ONE):
    rgb[0]-=add
  elif keydown(KEY_FOUR):
    rgb[0]+=add
  elif keydown(KEY_TWO):
    rgb[1]-=add
  elif keydown(KEY_FIVE):
    rgb[1]+=add
  elif keydown(KEY_THREE):
    rgb[2]-=add
  elif keydown(KEY_SIX):
    rgb[2]+=add
  elif keydown(KEY_PLUS) and add<255:
    add+=1
  elif keydown(KEY_MINUS) and add>1:
    add-=1
  else:
    change=0

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.