Pookkalam by Joyel Johny

Code

#************************************** BACKGROUND ******************************************************************************************************************************************************************************************* 

background = rectangle(w=300,h=300,fill="#6a040f",stroke="none") # creating dark brown background

#*************************************** PATTERN_6 ********************************************************************************************************************************************************************************************

def pattern6(n=4,h=18,w=12,x=123,stroke="none",stroke_width=1):  # defining a function to create rectangle pattern
    colors = ["#dc2f02","#9d0208","#370617","#f48c06"] # list of colors used to fill pattern
    rotation = 8                           
    shapes = []
    for value in range(n):
        for item in range(2):
            rotation = rotation + 8 * item
            rectangle_1 = rectangle(h=h,w=w,x=x,fill=colors[value],stroke=stroke,stroke_width=stroke_width)|rotate(rotation) |repeat(12,rotate(30))
            shapes.append(rectangle_1)
            h,x = h+2,x+12 
        h,x = h-4,x-24 
    return combine(shapes) # returns the combined shape

#********************************** BORDER_PATTERN ********************************************************************************************************************************************************************************************

border_pattern = circle(r=4,x=144,fill="#f27404",stroke="gold",stroke_width="2") | repeat(120,rotate(3)) # creating small yellow circle pattern around ring6 

#************************************* RING_5 *************************************************************************************************************************************************************************************************

ring5 = circle(r=118,fill="#FFDB49",stroke="none") # creating ring 5

#************************************  PATTERN_5  *********************************************************************************************************************************************************************************************

ellipse1 = ellipse(h=224,w=30,fill="#76BA1B",stroke="none")
ellipse2 = ellipse(h=224,w=30,fill="#A4DE02",stroke="none") | rotate(8)  
pattern5 = ellipse1 + ellipse2 | repeat(12,rotate(15))                       # creating leaf pattern inside ring 5

#********************************* RING_4 *****************************************************************************************************************************************************************************************************

ring4 = circle(r= 93,fill="	#fce46c",stroke="none") # creating ring 4

# ******************************* PATTERN_4 ***************************************************************************************************************************************************************************************************

def pattern4(x=0,rep=1,rot=0): # defining a function to create a petal shape
    total_rotation = 360
    point1 = point(x=x, y=-5)
    point2 = point(x=x+2, y=5)
    point3 = point(x=x+8, y=-1)
    triangle_shape = polygon([point1, point2, point3],fill="#66B032",stroke="none")
    circle_shape = circle(r=5,x=x,fill="#66B032",stroke="none")
    pattern = circle_shape + triangle_shape 
    return pattern | repeat(rot,rotate(total_rotation/rot)) # returns the pattern inside ring 4

#************************************ RING_3 **************************************************************************************************************************************************************************************************

ring3 = circle (r= 68,fill="#fdfa72",stroke="none",) # creating ring 3

#*********************************** PATTERN_3 ************************************************************************************************************************************************************************************************

def pattern3(r=5,x=20,rep=1,stroke="none",stroke_width="none"): # defining a function to create tower pattern
    total_rotation=360
    colors = ["#f29f04","#f27404","#f23004","#a60202"]
    value = [5,9,-17,1,0,0,3,8,-8,2,7,0,2,6,-3,2,7,5,1,0,0,3,4,5]
    i=0 # declaring a variable to iterate the value
    shapes = []
    for item in range(4):
        x=x+5*item # the value of x changes 
        circle1 = circle(r=r,x=x,fill=colors[item],stroke=stroke,stroke_width=stroke_width) | repeat(value[i],rotate(value[i+1])) | rotate(value[i+2]) | repeat(value[i+3],translate(x=value[i+4])) | translate(x=value[i+5])
        i=i+6
        shapes.append(circle1)
    return combine(shapes)| repeat(rep,rotate(total_rotation/rep)) # creates a pattern inside ring 3

#********************************* PATTERN_2 **************************************************************************************************************************************************************************************************

def pattern2(n=1,r=5,x=25,y=0,diff=0,stroke="black",stroke_width="none"): # defining a function to create concentric circle pattern
    total_rotation = 360
    colors = ["#B31B1B","#FFDB49","#FF8C00"]
    shapes = []
    for value in range(n):
        circle1 = circle(r=r,x=x,y=y,fill=colors[value],stroke=stroke,stroke_width=stroke_width)  | repeat(x,rotate(total_rotation/x))
        shapes.append(circle1)
        x=x-diff
    return combine(shapes) # creates a pattern inside ring 2

#*********************************** RING_1 ***************************************************************************************************************************************************************************************************

ring1 = circle(r=18,fill="gold",stroke="none") #creating ring 1

#*********************************** PATTERN_1 ************************************************************************************************************************************************************************************************

rectangle1 = rectangle(h=22,w=22,fill="#A52448",stroke="none") | repeat(3,rotate(60))
circle1 = circle(r=9,fill ="#FBFBFB",stroke="orange",stroke_width="5")
circle2 = circle(r=5,fill="#B31B1B",stroke="#FFDB49",stroke_width="3")
pattern1 = rectangle1 + circle1 + circle2  # creating pattern inside ring 1

#**************************** DISPLAY_THE_POOKKALAM *******************************************************************************************************************************************************************************************

pookkalam = background + pattern6(h=18,w=12,x=123) + border_pattern + ring5 + pattern5 + ring4 + pattern4(x=80,rep=12,rot=24) + ring3 + pattern3(r=5,x=46,rep=8,stroke="none") + pattern2(n=3,r=5,x=38,diff=8,stroke="none") + ring1 + pattern1
show(pookkalam) # concatenating all the shapes and display it on the canvas
print('''\t     " Happy Onam " ''')

#**********************************************************************************************************************************************************************************************************************************************