draws the christmas balls (without the tree). The positions, colors and sizes of the balls are more or less random. To create a drawing, just type xmas(); a more impressive effect is obtained with for k in range(10): xmas()
from math import * from kandinsky import * from random import * def ball(cx=160,cy=100,r=80,rc=2): for x in range(int(cx-r),int(cx+r+1)): for y in range(int(cy-r),int(cy+r+1)): cr=(x-cx)**2+(y-cy)**2 cr /= r**2 if cr<1: k=sqrt(1-cr) if rc==0: cc=color(int(k*255),int(k*255),0) elif rc==1: cc=color(0,int(k*255),int(k*255)) else: cc=color(int(k*255),0,int(k*255)) set_pixel(x,y,cc) def xmas(): for x in range(8): for y in range(5): ball(40*x+20+randint(-8,8),40*y+30+randint(-8,8),randint(8,16),randrange(3))