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)