couleurs.py

Created by elnix90

Created on March 07, 2023

2.48 KB

Ce programme permet de choisir une couleur au format R,G,B et de la renvoyer au format: “(R,G,B)” en utilisant la touche [OK]. Il n’est pas parfait et si vous voulez me suggérer des améliorations, vous pouvez me contacter sur discord: Elnix90#0116


from kandinsky import *
from ion import *
def couleur():
  fill_rect(0,0,320,222,"black")
  R=120
  G=120
  B=120
  draw_string("<    >",50,65,"green","black")
  draw_string("<    >",50,95,"green","black")
  draw_string("<    >",50,125,"green","black")
  draw_string(str(R),65,65,"red","white")
  draw_string(str(G),65,95,"green","black")
  draw_string(str(B),65,125,"blue","black")
  v=1
  while keydown(KEY_EXE) or keydown(KEY_OK):True
  while 1:
    if keydown(KEY_LEFT) or keydown(KEY_RIGHT) or keydown(KEY_UP) or keydown(KEY_DOWN):
      if keydown(KEY_UP) or keydown(KEY_DOWN):
        if keydown(KEY_UP):
          while keydown(KEY_UP):True
          v-=1
          if v<1:
            v=3
        if keydown(KEY_DOWN):
          while keydown(KEY_DOWN):True
          v+=1
          if v>3:
            v=1
      if keydown(KEY_LEFT) or keydown(KEY_RIGHT):
        if keydown(KEY_LEFT) and v==1:
          while keydown(KEY_LEFT):True
          R-=10
          if R<0:
            R=250
        elif keydown(KEY_LEFT) and v==2:
          while keydown(KEY_LEFT):True
          G-=10
          if G<0:
            G=250
        elif keydown(KEY_LEFT) and v==3:
          while keydown(KEY_LEFT):True
          B-=10
          if B<0:
            B=250
        elif keydown(KEY_RIGHT) and v==1:
          while keydown(KEY_RIGHT):True
          R+=10
          if R>250:
            R=0
        elif keydown(KEY_RIGHT) and v==2:
          while keydown(KEY_RIGHT):True
          G+=10
          if G>250:
            G=0
        elif keydown(KEY_RIGHT) and v==3:
          while keydown(KEY_RIGHT):True
          B+=10
          if B>256:
            B=0
      if v==1:
        fill_rect(60,60,40,100,"black")
        draw_string(str(R),65,65,"red","white")
        draw_string(str(G),65,95,"green","black")
        draw_string(str(B),65,125,"blue","black")
      elif v==2:#                                
        fill_rect(60,60,40,100,"black")
        draw_string(str(R),65,65,"red","black")
        draw_string(str(G),65,95,"green","white")
        draw_string(str(B),65,125,"blue","black")
      elif v==3:#                                
        fill_rect(60,60,40,100,"black")
        draw_string(str(R),65,65,"red","black")
        draw_string(str(G),65,95,"green","black")
        draw_string(str(B),65,125,"blue","white")
    fill_rect(160,0,160,222,(R,G,B))
    if keydown(KEY_OK) or keydown(KEY_EXE):
      while keydown(KEY_EXE) or keydown(KEY_OK):True
      print((str(R),str(G),str(B)))
couleur()

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.