Pookkalam by Sanal L S

Code

#outer layer
def outer_layer():
    colors = ["#1d161e", "#792514", "#b44b10", "#d48d18", "#eec10a", "#f9e249"]
    n = 9
    layer_0 = circle(r=150, fill = colors[0], stroke = "none")
    layer_1 = rectangle(w = 205, h = 205, fill = colors[1], stroke = "none") | repeat(360/n, rotate(n))
    layer_2 = rectangle(w = 195, h = 195, fill = colors[2], stroke = "none") | rotate(n/2) | repeat(360/n, rotate(n))
    layer_3 = rectangle(w = 185.5, h = 185.5, fill = colors[3], stroke = "none") | repeat(360/n, rotate(n))
    layer_4 = rectangle(w = 176.5, h = 176.5, fill = colors[4], stroke = "none") | rotate(n/2) | repeat(360/n, rotate(n))
    layer_5 = rectangle(w = 168, h = 168, fill = colors[5], stroke = "none") | repeat(360/n, rotate(n))
    return combine([layer_0, layer_1, layer_2, layer_3, layer_4, layer_5])

#repeating triangles in middle portion
def mid_triangles():
    c = circle(r=110, fill = "#CAC600", stroke = "none")
    s = rectangle(w = 155, h = 155, fill = "#718212", stroke = "none") | repeat(3, rotate(30))
    return combine([c,s])

#repeating circles in middle portion
def mid_circles():
    c1 = circle(x = 95, y = 0, r = 7.5, fill="#CAC600", stroke="#792514", stroke_width = 5)
    return c1 | rotate(30) | repeat(6, rotate(60))

#middle layer
def middle_layer():
    colors = ["#D01600", "#EF501C", "#F17A08", "#F6B133", "#E5E200", "#CAC600"]
    shapes = []
    width = 106
    step = width/8
    for i in range(8):
        d = width-(i*step)
        r = d/2
        shape = circle(x=d, y=0, r = d, fill=colors[i%6], stroke = "none")
        shapes.append(shape)
    s1 = combine(shapes) |rotate(-120)  | translate(x=100, y=10.5) | repeat(3,rotate(-120)) | scale(.46)
    s2 = s1 | rotate(60)
    return combine([s1,s2])

#kathakali
def kathakali():
    #circle behind face
    c1=circle(r=50,stroke_width=2)
    c2=circle(r=48,fill="red",stroke="green",stroke_width=3)
    c3=circle(x=39,r=3,stroke_width=4,stroke="gold",fill="black") | repeat(20,rotate(18))
    c4=circle(r=31,stroke="green",stroke_width=2)
    c5=circle(r=28,stroke="green",stroke_width=2)
    c6=circle(x=22,r=2,stroke="none",fill="white") | repeat(20,rotate(18))
    c7=circle(r=12,stroke="gold",stroke_width=10)
    c=combine([c1,c2,c3,c4,c5,c6,c7]) | translate(y=22)

    #face
    f1=ellipse(y=25,w=15,h=20,fill="orange",stroke="none") + circle(y=35,r=3,fill="maroon",stroke="none")
    f2=ellipse(y=-40,w=90,h=45,fill="white",stroke="grey") | repeat(2,scale(x=.75,y=.98))
    f3=circle(r=27,fill="red",stroke="none")
    f4=circle(r=27,stroke="gold", stroke_width = 1.5) | repeat(5,translate(y=-5))
    f5=ellipse(y=-30,w=50,h=60,fill="green",stroke="none")
    f=combine([f1,f2,f3,f4,f5])

    #forehead
    p1=point(x=-10,y=4)
    p2=point(x=-10,y=-8)
    p3=point(x=10,y=4)
    
    fh1 = rectangle(w=25,h=10, fill="gold", stroke="none")+ellipse(y=-5,w=25,h=12.5, fill="gold", stroke="none")
    fh2 = polygon([p1,p2,p3], fill="#ff5500", stroke="none") | repeat(2,scale(x=-1))
    fh3 = ellipse(y=-7,w=2.5,h=5,fill="maroon", stroke="orange")
    fh4=((fh1+fh2+fh3) | translate(y=-5))
       
    colors = ["orange","gold","white"]
    shapes=[]
    for i in range(3):
        s = circle(x=25,r=2,stroke="none",fill=colors[i]) | repeat(21,rotate(9)) | translate(y=-21-(2*i))
        shapes.append(s)
    arc = combine(shapes)
    fh=combine([fh4,arc])

    #ear
    ea1=circle(r=6,stroke="gold",fill="red", stroke_width = 6)
    ea2=circle(x=5,r=1,fill="orange",stroke="none")|repeat(8,rotate(45))
    ea3 = (combine([ea1,ea2])|translate(x=-29,y=-24)) | repeat(2,scale(x=-1))
    ea = ea3 | repeat(2,translate(y=18) | scale(.9))

    #eye
    ey1=line(x1=3,y1=-30,x2=15,y2=-25,stroke_width=2,stroke="black")+line(x1=15,y1=-25,x2=20,y2=-28,stroke_width=2,stroke="black")
    ey2=ellipse(x=4,y=-34,w=12,h=4,stroke="black",fill="white")+circle(x=4,y=-34,r=2,fill="black")|rotate(10)
    ey = combine([ey1, ey2]) | repeat(2,scale(x=-1))

    #nose
    n1=line(x1=-2,y1=-43,x2=2,y2=-43)
    n2=line(x1=-3,y1=-43,x2=-4,y2=-40) |repeat(2,scale(x=-1))
    n=combine([n1,n2])

    #lip
    l1=line(x1=-4,y1=-48,x2=4,y2=-48,stroke_width=2,stroke="red")
    l2=line(x1=-8,y1=-45,x2=-4,y2=-48,stroke_width=2,stroke="red") |repeat(2,scale(x=-1))
    l3=circle(x=-8,y=-45,r=2,fill="red",stroke="none") |repeat(2,scale(x=-1))
    l = combine([l1,l2,l3]) | translate(y=-2)
    
    #background
    cb = circle(r=53, fill="#4f1937", stroke = "none")
    
    return cb + (combine([c,f,fh,ea,ey,n,l]) |scale(.7) | translate(y=-3))


#showing all elements layer by layer
show(outer_layer(), mid_triangles(), mid_circles(), middle_layer(), kathakali())