chromatic_circle.py

Created by uncurieux

Created on May 11, 2019

1.08 KB

The name is explicit. There isn’t the intensity variations due to the place it takes, but it’s easy to do.


from math import *
from cmath import *
from kandinsky import *
def chroma():
  r=255
  g=0
  b=0
  for j in range(111):
    a=int((j*677)/111)
    for i in range(2*a):
      e=int((j*cos(i*(pi/a))+160).real)
      c=int((j*sin(i*(pi/a))+111).real)
      for k in range(3):
        if k==0:
          z=104.5+207*1j
        elif k==1:
          z=271+111*1j
        else:
          z=104.5+15*1j
        p=phase((e+c*1j-160-111*1j)/(z-160-111*1j))
        if p<0:
          p=2*pi+p
        d=int((765*p)/pi)
        if d<=255:
          if k==0:
            r=d
          elif k==1:
            g=d
          else:
            b=d
        elif d>255 and d<=765:
          if k==0:
            r=255
          elif k==1:
            g=255
          else:
            b=255
        elif d>765 and d<=1020:
          if k==0:
            r=1020-d
          elif k==1:
            g=1020-d
          else:
            b=1020-d
        else:
          if k==0:
            r=0
          elif k==1:
            g=0
          else:
            b=0
      set_pixel(e,c,color(r,g,b))