palette.py

Created by gianfranco-oddenino

Created on July 09, 2018

427 Bytes

The script draws the color palette that can be built on the calculator. Horizontal axis: the hue changes from left to right. Vertical axis: in the upper half the brightness changes with the maximum saturation, in the lower half the saturation changes with the maximum brightness.


from kandinsky import *
from math import *

def hsv2rgb(h,s,v):
  i=int(h*6)
  f=h*6-i
  p,q,t=v*(1.-s),v*(1.-s*f),v*(1.-s*(1.-f))
  i%=6
  return ((v,t,p),(q,v,p),(p,v,t),(p,q,v),(t,p,v),(v,p,q))[i]

for x in range(320):
  for y in range(222):
    if y<111:
      s,v=1,y/111
    else:
      s,v=(222-y)/111,1
    r,g,b=hsv2rgb(x/320,s,v)
    c=color(floor(255*r),floor(g*255),floor(b*255))
    set_pixel(x,y,c)

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.