Code
"""
Code-a-Pookkalam by Tinkerhub and Mon-school
Coded By: Ritesh Chhetri
"""
#Since we are creating a pookkalam we need Flowers
#Cherry blossoms cos...looks cool!
def sakura(color="pink"):
e=ellipse(x=50,y=0,h=30,w=100,fill="white",stroke=color,stroke_width=5)
e1=ellipse(x=50,y=0,h=30,w=64,fill=color,stroke="none")|scale(0.93)
e2=e|rotate(10)
e3=e|rotate(-10)
petal=e3+e2+e1
l=line(0,0,8,60)
rc=circle(r=5,x=8,y=60,fill="red",stroke="none")
rod_with_dot=l+rc
rod_with_dot2=rod_with_dot|rotate(-20)
rod_thingy=rod_with_dot+rod_with_dot2
petal=petal|rotate(72)
part_1=petal+rod_thingy
petals=part_1|repeat(5,rotate(72))
core=circle(r=30,stroke="none",fill="white")
shade=circle(r=27,stroke="#00000010",stroke_width=20)
flower=petals+core+shade
return flower
#Not exactly as hibiscus but discounted version
def hibiscus(petalc="red"):
fpetal=ellipse(w=50,h=35,x=25,y=0,fill="#C0C0C0",stroke="none")
dpetal=ellipse(w=50,h=35,x=25,y=0,fill=petalc,stroke="none")|scale(0.9)
cpetal=ellipse(w=50,h=35,x=25,y=0,fill="#00000050",stroke="none")|scale(0.8)
petal=fpetal+dpetal+cpetal
petals=petal|repeat(5,rotate(72))
centre=circle(r=10,fill="yellow")
flower=petals+centre
x=0
dots=[]
while x<40:
a,b=random(-8,8),random(-8,8)
cer=random(0,255)
dot=circle(r=0.5,x=a,y=b,stroke="none",fill=color(r=cer,g=20,b=20))
dots.append(dot)
x=x+1
dots=combine(dots)
flower=flower+dots
return flower
#Ah yes can't forget this...Noted
def marigold(r=255,g=165,b=0):
vizi=0.1
side=100
flower=[]
roc=0
for but in range(8):
flo=rectangle(w=side,h=side,fill=color(r,g+(but*15),b,vizi),stroke="none")|rotate(roc)|repeat(8,rotate(10))
flower.append(flo)
side-=10
vizi+=0.1
roc+=10
return combine(flower)
#Leaf...yeah..obviously
def leaf(colorc="#00FF00"):
lev=ellipse(x=50,y=0,w=100,h=35,fill=colorc,stroke="none")
shade=ellipse(x=20,y=0,w=40,h=25,fill="#00000050",stroke="none")
mvein=line(0,0,100,0)
bvein=line(15,0,30,-15)|repeat(5,translate(x=12))
tvein=line(10,0,30,15)|repeat(5,translate(x=12))
leaf=lev+mvein+bvein+tvein+shade
return leaf
#Now we do need a design
#Nice looking squares
def centers(val):
if val==1:
flow=sakura("blue")
else:
flow=sakura("red")
sq_f=[]
for d in range(4):
s=flow|scale(0.1)|repeat(4,translate(x=15))
s=s|translate(x=-40,y=(d*15))
sq_f.append(s)
sq_f=combine(sq_f)
return sq_f|translate(x=-15,y=11)
def center_square():
roc=0
square=[]
sq1=centers(1)
sq2=centers(2)
for dub in range(0,8):
if dub%2==0:
sq22=sq2|rotate(roc)
square.append(sq22)
if dub%2!=0:
sq11=sq1|rotate(roc)
square.append(sq11)
roc+=45
square_flower=combine(square)
square_flower=square_flower|scale(0.8)
return square_flower
#Main show
def main_flower():
core=hibiscus("red")
core=core|scale(0.8)
trileaf=leaf()|scale(0.5)|rotate(50)|repeat(3,rotate(120))
finish=trileaf+core
return finish
ree=center_square()
#Center background
def center_bg():
center=rectangle(w=100,h=100,fill="black",stroke="none")
center=center|repeat(10,rotate(20))
return center
#Outer base
def outer_circle():
finish=[]
disp=0
for nums in range(3):
flower=marigold()|scale(0.5)|translate(x=100-disp)|repeat(12,rotate(30))
finish.append(flower)
disp+=15
flower_2=hibiscus("#FFFFFF")|scale(0.5)|translate(x=100)|repeat(12,rotate(30))
finish.append(flower_2)
return combine(finish)
#Flower circle
def flower_cir():
finish=[]
for arran in range(12):
if arran%2==0:
core=hibiscus("red")
core=core|scale(0.8)
trileaf=leaf()|scale(0.5)|rotate(random(180))|repeat(5,rotate(72))
else:
core=marigold(r=255,g=60,b=250)
core=core|scale(0.5)
trileaf=leaf()|scale(0.4)|rotate(random(180))|repeat(12,rotate(30))
flower=trileaf+core|scale(0.3)|translate(x=100)|rotate(30*arran)
finish.append(flower)
return combine(finish)
#Background
def background():
wid=0
finish=[]
opc=0
for ded in range(11):
cc=color(255,192,203,1-opc)
flower=sakura(cc)|scale(0.2)|translate(x=-150,y=(150-wid))|repeat(20,translate(x=30))
wid+=30
opc+=0.1
finish.append(flower)
return combine(finish)
#And a lovely scribbly text
#H
H1= rectangle(w=5,h=20,y=10,fill="#9ACD32",stroke="none")|translate(x=-5)
H2=rectangle(w=5,h=20,y=10,fill="#9ACD32",stroke="none")|translate(x=3)
H3=rectangle(w=9,h=5,y=10,fill="#9ACD32",stroke="none")
sH=H1+H2+H3
#A
A1=rectangle(w=5,h=40,y=10,fill="#7CFC00",stroke="none")|rotate(40)|translate(x=18)
A2=rectangle(w=5,h=40,y=10,fill="#7CFC00",stroke="none")|rotate(-40)|translate(x=-18)
A3=rectangle(w=24,h=5,y=5,fill="#7CFC00",stroke="none")
sA=A1+A2+A3
#P
P1=rectangle(w=5,h=30,y=10,fill="#008000",stroke="none")
P2=circle(x=7,y=18,r=9,fill="#008000",stroke="none")
sP=(P1+P2)
#Y
Y1= rectangle(w=5,h=20,y=10,fill="#00FF00",stroke="none")|repeat(3,rotate(120))
sY=Y1|rotate(180)
#O
sO = ellipse(w=20,h=24,fill="#6B8E23",stroke="none")
#N
N1=rectangle(w=5,h=20,y=10,x=-8,fill="#7FFF00",stroke="none")
N2=rectangle(w=5,h=20,y=10,x=8,fill="#7FFF00",stroke="none")
N3=rectangle(w=5,h=20,fill="#7FFF00",stroke="none")|rotate(45)|translate(y=8)
sN=N1+N2+N3
#M
M1=rectangle(w=5,h=20,y=10,x=12,fill="#008000",stroke="none")
M2=rectangle(w=5,h=20,y=10,x=-12,fill="#008000",stroke="none")
M3=rectangle(w=5,h=20,fill="#008000",stroke="none")|rotate(35)|translate(y=8,x=-6)
M4=rectangle(w=5,h=20,fill="#008000",stroke="none")|rotate(-35)|translate(y=8,x=6)
sM=M1+M2+M3+M4
Hx=sH|rotate(-60)|translate(x=-120,y=-100)
Ax=sA|rotate(-40)|scale(0.6)|translate(x=-100,y=-120)
Px=sP|rotate(-30)|scale(0.8)|translate(x=-80,y=-140)
Py=sP|rotate(0)|scale(0.8)|translate(x=-50,y=-145)
Yx=sY|rotate(0)|scale(0.7)|translate(x=-20,y=-135)
Ox=sO|rotate(0)|translate(x=30,y=-135)
Nx=sN|rotate(20)|translate(x=60,y=-135)
Ay=sA|rotate(30)|scale(0.6)|translate(x=80,y=-115)
Mx=sM|rotate(30)|translate(x=115,y=-110)
Txt=combine([Hx,Ax,Px,Py,Yx,Ox,Nx,Ay,Mx])
#Finally to call them
bgm=background()
inner_bgm=outer_circle()
inner_flower=flower_cir()
center_zone=center_bg()
center_des=center_square()
flower=main_flower()
text=Txt|scale(0.8)|translate(y=-30)
final=bgm+inner_bgm+inner_flower+center_zone+center_des+flower+text
show(final)