Pookkalam by Amjad C P

Code

'''
Author        : Amjad CP
Program       : Code A Pookalam
Finished Date : 17 Aug 2021 1.42 AM

'''

#outer part of pookalam
def Out():
    # base of pookalam
    base = circle(r=149, fill='#99015a', stroke='none') #4b4132 #99015a
    
    # layer just above base (layer 1)
    c =circle(r=125, fill='#fbf022', stroke='none')
    cover = circle(r=17, x=0, y=130, fill='#99015a', stroke='none') | repeat(24, rotate(15)) # this cover used to feel overlapping from 'base'
    layer1 = c + cover

    # layer just above layer 1 (layer 2)
    c = circle(r=100, fill='#30B700', stroke='none')  
    cover = circle(r=13, x=0, y=110, fill='#fbf022', stroke='none') | repeat(24, rotate(15)) # this cover used to feel overlapping from 'layer 1'
    
    # jasmin flowers in 'base'
    jasmins= ellipse(x=0,y=10,w=10,h=20,fill="#f6fafd", stroke='none') | scale(.3) | repeat(6,rotate(60)) | translate(y=110) | repeat(12, translate(x=10, y=10) | rotate(-30)) | translate(x=-15, y=25)

    layer2 = c + cover + jasmins

    out = base + layer1 + layer2
    return out  # returning the whole outer part of pookalam

# center of pookalam
def Center():
    center_base = circle(r=88, fill='#6c345c', stroke_width=3, stroke='none') #99015a  
    moon = circle(r=10, x=25, y=65, fill='#fcae17', stroke='none')

    # creating kaakakal ( crows )
    c = circle(r=10, x=-10,y=0) | repeat(2, translate(x=19)) 
    cover = rectangle(w=42, h=12, fill='#6c345c', stroke='none') | translate(y=-5)
    crow1 = (c + cover) | scale(.5) | translate(x=40, y=45) | repeat(2, translate(x=5, y=-10))
    crow2 = (c + cover) | scale(.5) | translate(x=-40, y=45) | repeat(2, translate(x=-5, y=-11))
    crow3 = (c + cover) | scale(.5) | translate(x=-40, y=45) | repeat(2, translate(x=15, y=-15))
    crows = crow1 + crow2 +crow3
    
    center = center_base + moon + crows
    return center # returning center

#trees in center of pookalam   | Consider as Coconut tree :)
def Trees():
    # stump part
    e1 = ellipse(stroke_width='9') | rotate(90)
    r1 = rectangle(w=70, h=210,stroke='none', fill='#6c345c') | translate(x=20, y=0) #6c345c
    stump1 = e1 + r1 | scale(.5)
    
    e2 = ellipse(stroke_width='9') | rotate(-40)
    r2 = rectangle(w=70, h=210,stroke='none', fill='#6c345c') | translate(x=-20, y=0) | rotate(50) 
    stump2 = e2+r2 | scale(.5) | translate(x=150, y=100)
    
    stumps = stump1 + stump2    

    #leaf part
    main = line(x1=0,y1=0,x2=125,y2=0, fill='#368809')

    lin1 = line(x1=10,y1=0,x2=25,y2=20, fill='#368809')
    lin2 = line(x1=10, y1=0, x2=25, y2=-20, fill='#368809')
    lin = ( lin1+lin2 ) | repeat(26, translate(x=5) | scale(.98))

    Lin1 = line(x1=105,y1=0,x2=115,y2=10, fill='#368809')
    Lin2 = line(x1=105,y1=0,x2=115,y2=-10, fill='#368809')
    Lin = ( Lin1+Lin2 ) | repeat(8, translate(x=5) | scale(.98))


    leaf = main + lin + Lin
    leafs1 = leaf | scale(.5) | rotate(-80) | repeat(2, rotate(230) | translate(x=-10))
    leafs2 = leaf | rotate(-20) | repeat(2, rotate(220) | translate(x=-10))  | translate(x=0, y=30)  | scale(.7) 
    leafs_final1 = leafs2 + leafs1 | scale(.5) | rotate(-30) | translate(x=-10, y=45) 
    leafs_final2 = leafs_final1  | rotate(90) | translate(x=160, y=150)
    
    tree1 = stump1 + leafs_final1 | scale(.5) | rotate(-30) | translate(x=-50, y=-5)
    tree2 = stump2 + leafs_final2 | scale(.5) | rotate(-30) | translate(x=-40, y=-10)
    trees = tree1 + tree2 

    return trees # returning the trees

#vallam in center of pookalam     | Consider as Chundan vallam :)
def Vallam():
    #body of vallam
    lin = line(stroke_width=10)
    e = ellipse(h=100, w=60, x=72, y=10, stroke_width=5)
    r1 = rectangle(w=100, h=90, fill='#6c345c', stroke='none', x=39, y=50)
    r2 = rectangle(w=152, h=90, fill='#6c345c', stroke='none', x=32, y=-50)
    body = lin+e+r1+r2

    #panka
    upper = line(x1=-90,y1=20,x2=-60,y2=-10, stroke_width=2)
    lower = line(x1=-60,y1=-10,x2=-50,y2=-20, stroke_width=5)
    pankas = (upper+lower) | translate(x=146) | repeat(8, translate(x=-20))

    #front of vallam
    p1 = point(x=-100,y=0)
    p2 = point(x=-100,y=10)
    p3 = point(x=-130,y=0)
    front = polygon([p1, p2, p3], stroke_width=5, fill='black') | translate(y=-3)

    vallam = body+pankas+front | scale(.35) #| translate(x=16, y=-30)
    vallam1 = vallam | scale(.65) | translate(x=6, y=-60) #| rotate(10)
    vallam2 = vallam1 | scale(.7) | translate(x=-15, y=0)
    vallam_final = vallam1 + vallam2
    
    return vallam_final # returning the grate 'chundan vallam' :)


#the kathakali face    | this is masterpiece of myself :)
def Kathakali_face():
    #head
    e1 = ellipse(fill='white') | translate(y=-70)
    e2 = ellipse(w=200, h=150, fill='green', stroke='none') | rotate(90)
    r1 = rectangle(w=140, h=20, fill='red', stroke='none') | translate(y=55)

    #forehead
    p1 = point(x=-30, y=50)
    p2 = point(x=0, y=45)
    p3 = point(x=30, y=50)
    p4 = point(x=30, y=40)
    p5 = point(x=0, y=20)
    p6 = point(x=-30, y=40)
    shape = polygon([p1, p2, p3, p4, p5, p6], fill='yellow', stroke='none') | translate(y=-10) # the white shape in forehead (the kurri)

    c = circle(r=4, fill='red', stroke='none') | translate(y=28) | repeat(2, translate(y=-25))
    lin = line(x1=7, y1=18, x2=-7, y2=18, stroke='white', stroke_width=6)

    head = e1 + e2+ r1 + shape + c + lin

    #ears
    c1 = circle(r=25,fill='orange', stroke='green', stroke_width=4)
    c2 = circle(r=10, stroke='red', stroke_width=10)
    c3 = circle(r=5, stroke='white', stroke_width=3)
    upper_ear = (c1 + c2 + c3 ) | translate(y=50)

    c1 = circle(r=40,fill='yellow', stroke='green', stroke_width=4)
    c2 = circle(r=4, x=0,  y=30, fill='red', stroke='none') | repeat(12, rotate(30))
    c3 = circle(r=22, stroke='white', stroke_width=3)
    c4 = circle(r=15, stroke_width=10, stroke='red')
    lower_ear = (c1 + c2 +c3 + c4) 

    ears = (upper_ear + lower_ear) | translate(x=-90, y=-5) | repeat(2, translate(x=180))

    #eyes
    e1 = ellipse(w=80, h=40, fill='black') | translate(x=-8, y=-5)
    e2 = ellipse(w=50, h=20, fill='white', stroke='none')
    c1 = circle(r=6, fill='grey')
    c2 = circle(r=2, fill='black')
    eye1 = (e1 + e2 + c1 + c2) | scale(.65) | translate(x=-50)

    e1 = ellipse(w=80, h=40, fill='black') | translate(x=8, y=-5)
    e2 = ellipse(w=50, h=20, fill='white', stroke='none')
    c1 = circle(r=6, fill='grey')
    c2 = circle(r=2, fill='black')
    eye2 = (e1 + e2 + c1 + c2) | scale(.65) | translate(x=50)

    eyes = (eye1 + eye2) | scale(.6) | translate(y=-4)

    #nose 
    p1 = point(x=-10, y=0)
    p2 = point(x=-10, y=-50)
    p3 = point(x=0, y=-55)
    p4 = point(x=10, y=-50)
    p5 = point(x=10, y=0)
    shape = polygon([p1, p2, p3, p4, p5]) | translate(y=-5)
    lin = line(x1=-10, y1=0, x2=10, y2=0, stroke='green') | translate(y=-5)
    nose = shape +lin

    #mouth
    e1 = ellipse(w=60, h=10, fill='red', stroke='none')
    e2 = ellipse(w=20, h=10, fill='red', stroke='none') | translate(x=-35, y=-15) | rotate(-30)
    e3 = e2 | rotate(-130) | translate(x=10, y=-24)
    mouth = (e1 + e2 + e3) | translate(y=-70)

    #hat
    p1 = point(x=-20, y=0)
    p2 = point(x=20, y=0)
    p3 = point(x=0, y=40)

    e1 = ellipse(h=50, w=150, fill='white', stroke='green', stroke_width=5) | translate(y=-100)      
    e2 = ellipse(h=50, w=140, fill='#cf4200', stroke='green', stroke_width=5) | translate(y=-80)
    e3 = ellipse(h=50, w=130, fill='#ca0001', stroke='green', stroke_width=5) | translate(y=-60)
    e4 = ellipse(h=50, w=120, fill='#cf4200', stroke='green', stroke_width=5) | translate(y=-40)
    e5 = ellipse(h=50, w=110, fill='#ca0001', stroke='green', stroke_width=5) | translate(y=-20)
    e6 = ellipse(h=50, w=100, fill='#cf4200', stroke='green', stroke_width=5) | translate(y=0)
    e7 = ellipse(h=50, w=90, fill='#ca0001', stroke='green', stroke_width=5) | translate(y=20)
    e8 = ellipse(h=50, w=80, fill='#cf4200', stroke='green', stroke_width=5) | translate(y=40)
    e9 = ellipse(h=50, w=70, fill='#cf4200', stroke='green', stroke_width=5) | translate(y=60)
    e10 = polygon([p1, p2, p3], fill='#ca0001', stroke='none', stroke_width=5) | translate(y=97)     # it is a polygon
    e11 = ellipse(h=50, w=50, fill='#ca0001', stroke='none', stroke_width=5) | translate(y=80)
    corn = (e1 + e2 + e3 + e4 + e5 + e6 + e7 + e8 + e9 + e10 + e11) | scale(.5) | translate(y=75)

    c1 = circle(r=140, fill='red', stroke='white')| translate(y=50)
    c2 = circle(r=120, stroke='white', stroke_width=3)| translate(y=50)
    c3 = circle(r=116, stroke='green', stroke_width=4, fill='yellow')| translate(y=50)
    c4 = circle(r=100, stroke='green', stroke_width=4, fill='blue')| translate(y=50)
    c5 = circle(r=80, stroke='green', stroke_width=4, fill='yellow')| translate(y=50)
    vattam = (c1 + c2 + c3 + c4 + c5) | scale(.5)

    face = (head + ears + eyes + nose + mouth) | translate(y=-30) | scale(.48)
    kathakali_face = (vattam + face + corn) | scale(.45) | translate(y=0)

    return kathakali_face  # returning my masterpiece :)

# whole components calling from here (the KAPPITHAAN) :)
def main():
    show(  
        Out(),
        Center(),
        Trees(),
        Vallam(),
        Kathakali_face()
        )
    print('''

         Author        : Amjad CP
         Program       : Code A Pookalam
         Finished Date : 17 Aug 2021 1.42 AM

         --------- HAPPY ONAM --------

         ''')

if __name__ == '__main__':   
    main() # everything starts here