Code
def make_grid_v2(n):
width = 300
d = width/n
xstart = -width/2 + d/2
ystart = width/2 - d/2
shapes = []
for i in range(n):
for j in range(n):
x = xstart + d*j
y = ystart - d*i
shape = make_shape(d, row=i, col=j, n=n) | translate(x=x, y=y)
shapes.append(shape)
return combine(shapes)
def make_shape(width, row, col, n):
return distorted_square(0.8*width, row, col, n)
def random_color():
r = random(255)
g = random(255)
b = random(255)
return color(r=r, g=g, b=b, a=0.8)
def distorted_square(width, row, col, n):
distortion_factor = row / n
s = rectangle(w=width, h=width, fill=random_color(), stroke = "none")
angle = distortion_factor * random(-30, 30)
return s | rotate(angle)
shape = make_grid_v2(16)
e=ellipse(w=55,h=30,fill='white',stroke='none')
a=e | translate(y=5)
s=ellipse(w=50,h=36,fill='black')+ e + a
t=s | translate(y=75)
w=t | translate(x=0,y=-45)
l1=line(x1=0,y1=0,x2=0,y2=16)
l2=l1 | translate(y=15)
l3=l2 | translate(x=0.3)
o=ellipse(y=35,w=20,h=10,fill='black')
q=ellipse(w=30,h=25,fill='black')
r=q | translate(x=-5,y=60)
p=r | rotate(20)
c1=circle(r=8,fill='white',stroke='none')
c2= c1 | translate(x=-18.7,y=57)
c3=circle(r=4,fill='black')
c4= c3 | translate(x=-18,y=57)
c5=p+c2+c4
c5=c5 | rotate(-2)
c6=c5 | scale(x=-1)
d=ellipse(x=-13,y=-60,w=25,h=70,fill="black") | rotate(112)
e=ellipse(x=-35,y=-30,w=25,h=70,fill="black") | rotate(325)
f=ellipse(x=23,y=-75,w=35,h=70,fill="black")
g=ellipse(x=-23,y=-75,w=35,h=70,fill="black")
c=ellipse(x=0,y=-25,w=90,h=110,fill='black')+ ellipse(x=0,y=-25,w=83,h=103,fill='white')+ellipse(x=0,y=50,w=110,h=100,fill='black')+ellipse(x=0,y=50,w=106,h=96,fill='white')
el1=ellipse(w=38,h=30,fill='black') | translate(x=-20,y=103)
el=el1 | rotate(12)
el2=el | scale(x=-1)
teddy = combine([el,el2,d,e,f,g,c,w,l2,l3,o,c5,c6])
show(shape)
show(teddy)