Do a lot of things about colors and things you cannot do normally with Kandinsky, such as lines or circles. Needed for my program loading.
from kandinsky import set_pixel as set,fill_rect as rect from ion import keydown as k from math import radians,cos,sin def pix(x,y,c=(255,)*3,e=1,g=-1): if (320>x>0-e)and(222>y>0-e): if g!=-1:c=gradiant(g) if e==1:set(x,y,c) else:rect(x,y,e,e,c) def line(x0,y0,x1,y1,c=(255,)*3,e=1,p=1): dx,dy=x1-x0,y1-y0 steps=max(abs(dx),abs(dy)) if steps==0:pix(x0,y0,c,e);return xinc,yinc,d,i=dx/steps/p,dy/steps/p,c,0 while i<steps: if c==-1:d=gradiant(i*1530/steps) pix(round(x0),round(y0),d,e) x0+=xinc y0+=yinc i+=1/p def gradiant(n): n,p,r,g,b=n%1530,n%1530%255,0,0,0 if n<255:r,b=255,p elif n<510:r,b=255-p,255 elif n<765:g,b=p,255 elif n<1020:g,b=255,255-p elif n<1275:r,g=p,255 elif n<1530:r,g=255,255-p return (r,g,b) def circle(xc,yc,r=50,c=(255,)*3,e=1,f=False): for i in range(90): ar=radians(i) x_inc=round(r*cos(ar)) # x_inc=round(r-i) y_inc=round(r*sin(ar)) if not f: pix(xc+x_inc,yc+y_inc,c,e) pix(xc-x_inc,yc-y_inc,c,e) pix(xc+x_inc,yc-y_inc,c,e) pix(xc-x_inc,yc+y_inc,c,e) else: rect(xc+x_inc,yc-y_inc,1,2*y_inc,c) rect(xc-x_inc,yc-y_inc,1,2*y_inc,c)