Pookkalam by Thejas Kiran P S

Code

def heart(h,w,fill,stroke,stroke_width):    
    p1=point(x=0,y=h)     
    p2=point(x=w/2,y=0)    
    p3=point(x=-w/2, y=0)    
    t=polygon([p1,p2,p3],fill=fill,stroke=stroke,stroke_width=stroke_width)       
                                                                                  
    c1=circle(r=w/4 + 1,fill=fill,stroke=stroke,stroke_width=stroke_width)    
    c2=circle(r=w/4 + 1,fill=fill,stroke=stroke,stroke_width=stroke_width)    
    c2 = c2 | translate(x=23,y=-3)     
    c1 = c1 | translate(x=-23,y=-3)    
        
    return combine([t,c1,c2])          
    
h=heart(100,100,"#ffe040","",0)    
h1=heart(100,100,"#225f28","",0) | scale(1.2)  | translate(y=-5)
heart=h1+h | scale(0.55)
heart= heart | rotate(90) | translate(x=100) | repeat(6,rotate(60) | translate(y=-40,x=20)) | translate(x=-45)



def roundedRectangle(h,w,r,fill):
    y=h/2
    x=w/2
    corners=[
                [x,y],
                [x,-y],
                [-x,y],
                [-x,-y],
            ]
    shapes= []
    points = [
                [x-r,y],
                [x,y-r],
                [x,-y+r],
                [x-r,-y],
                [-x+r,-y],
                [-x,-y+r],
                [-x,y-r],
                [-x+r,y],
            ]
    def fixpos(x):
        return  x+r if x < 0 else x-r
    for x,y in corners:
        shapes.append(circle(x=fixpos(x),y=fixpos(y),r=r,fill=fill,stroke="none"))
    for index,[x,y] in enumerate(points):
        points[index]= point(x=x,y=y)
    shapes.append(polygon(points, fill=fill,stroke="none"))
    return combine(shapes)

top= roundedRectangle(30,85,5,"#05BFCE") | translate(x=-20)
top= top +  (roundedRectangle(30,30,5,"#0060FF") | translate(x=50))
top= top | translate(y=50)
mid= roundedRectangle(30,130,5,"#ffcd10") 
bottom= roundedRectangle(30,50,5,"#EE1700") | translate(x=-40)
bottom= bottom +  (roundedRectangle(30,25,5,"#95BF15") | translate(x=12.5))
bottom= bottom +  (roundedRectangle(30,25,5,"#205B67") | translate(x=52.5))
bottom= bottom | translate(y=-50)
logo=top+mid+bottom
logo=logo | scale(0.25)


c=circle(fill="white",r=25)

def corner(r=40,h=60,w=18,cfill="#17005a",pfill="#fe7676"):
    
    center=circle(r=r,fill=cfill,x=0,y=0)
    
    petal=ellipse(w=w,h=h,fill=pfill,stroke="none") | translate(x=5)| translate(y=60) | repeat(23,rotate(16))
    
    flower=petal + center | scale(0.7)
    flower=flower | translate(x=150,y=150) | repeat(2,scale(-1))
    flower=flower + (flower | scale(y=-1))
    
    return flower


cornerf=corner()

bg=circle(r=300,fill="white")

el=ellipse(h=180,w=130,fill="#ea9191",stroke="none") | repeat(3,rotate(120))
elbg=ellipse(h=180,w=130,fill="#17005a",stroke="none") | repeat(3,rotate(120)) | scale(1.05)
el=elbg + el


def rounded(h=100,w=25,fill="black",angle=0,x=0,y=0,r=5):
    ret= roundedRectangle(h=h,w=w,fill=fill,r=r) | rotate(angle) | translate(x=x,y=y)
    return ret

H= rounded(x=25) + rounded(x=-25) + rounded(angle=90,h=50)
A= rounded(angle=90,h=50,y=-20) + rounded(angle=25,x=25,) + rounded(angle=-25,x=-25) + (circle(r=16,fill="black") | translate(y=44))
P= (rectangle(fill="black",h=50,w=40) | translate(x=-25))+ (circle(fill="black",r=25) | translate(x=0))
P= P +((rectangle(fill="white",h=50,w=40,stroke="none") | translate(x=-25))+ (circle(fill="white",r=25,stroke="none") | translate(x=0)) | scale(0.4)) | translate(x=50)
X=P + rounded(y=-24,x=15)

H=H | translate(x=-110)
X=X | translate(x=80,y=30)
Y= rounded(y=-20,h=70) + rounded(h=70,angle=-45,x=25,y=25) + rounded(angle=45,x=-25,y=25,h=70)


O=circle(r=70,fill="black")
O=O+ circle(r=35,stroke="none",fill="white") | translate(y=-200) | scale(0.8) | translate(x=-100)

N=rounded(x=-30) + rounded(angle=35) + rounded(x=30) | translate(y=-160,x=30)

M=(rounded(angle=-10) | translate(x=-20))+ rounded(angle=10)
M=(rounded() |translate(40)) + (rounded() |translate(-45)) + (rounded(angle=15) | translate(x=-15)) + (rounded(angle=-15) | translate(x=15)) + (rounded(angle=0,h=20,w=40,y=40,x=-35)) +(rounded(angle=0,w=35,h=20,y=40,x=35))+(rounded(angle=0,w=25,h=20,y=-40)) 
#H=H |scale(0.2)
#A=A |scale(0.2)
M=M| translate(x=280,y=-150)
X=X + (X | translate(x=100)) + H + A + (Y |translate(x=330)) + O + N + (A|translate(y=-160,x=150)) + M| scale(0.2)
X=(X | scale(0.5)) | translate(y=-120,x=-10)

#rose
rose=ellipse(h=180,w=130,fill="crimson",stroke="black") | repeat(3,rotate(120))

sc=1
for i in range(5):
    sc-=.19
    rose=rose +(( rose | rotate(30)) | scale(sc))
    
rose=(rose | scale(0.3))



# sadhya
def sadhya():
    ela=ellipse(h=50,w=150,fill="#34a301",stroke="none")
    ela+=line(x1=-50,y1=0,x2=75,y2=0,stroke="white")
    ela+=rounded(h=60,w=60,x=-45,fill="white")
    chor=(ellipse(h=5,w=10,fill="white",stroke="none"))
    chor= ((chor | translate(x=30))| repeat(36,rotate(10)))
    chor=chor + (chor | scale(0.75))
    chor=chor + (chor | scale(0.75))
    chor=chor + (ellipse(h=5,w=10,fill="white",stroke="none") | translate(x=10))| repeat(36,rotate(10))
    chor+=circle(r=10,fill="gold",stroke="none")
    chor|=scale(.3)
    chor|=translate(x=25)
    pappadam=circle(r=10,fill="gold",stroke="none") | translate(y=10)
    puli= ellipse(w=10,h=6,fill="black") | translate(x=50,y=10)
    achaar= ellipse(w=10,h=6,fill="crimson",stroke="none") | translate(x=0,y=-10)
    


    return ela + chor + pappadam + puli + achaar


sadhya1= (sadhya() | scale(.45)) | rotate(90) | translate(y=-140,x=-50)
sadhya2= (sadhya() | scale(.45)) | rotate(-90) | translate(y=-115,x=50)

show(bg,el,cornerf,heart,c,logo,X,sadhya1,sadhya2)