Explore
Courses
Batches
Sketches
Statistics
Code a Pookkalam
Jobs
Devsprint
People
Course Creation
Create a Course
Guidelines
Resources
Support
Blogs
My Profile
About Us
Login
Sketches
0
.
By
Jyothi N Nair
Run
""" # 2D is set by default _3D = False # Toggle this to True to view like first-person # Helper to combine elements def combine(elements): combined = elements[0] for elem in elements[1:]: combined = combined | elem return combined # USED TO DRAW CIRCLES AND ARCS USING FLOWERS def Petal_Stroke_Circle(flower="ROSE", r=50, joints=10, angle=36, size=1, fill="white", stroke="grey"): shape = Flower(type=flower, fill=fill, stroke=stroke) | scale(size) | translate(x=r) | repeat(int(joints), rotate(angle)) return shape # USED TO DRAW SQUARE STROKES USING FLOWERS def Petal_Stroke_Square(flower_type="ROSE", columns=2, size=1, width=50, fill="white", stroke="grey"): shape = flower_lines(flower=flower_type, size=size, width=width, fill=fill, stroke=stroke, divisions=columns) shape1 = shape | rotate(90) | repeat(2, translate(x=0, y=width)) shape2 = shape1 | rotate(-90) | translate(y=width) return combine([shape, shape1, shape2]) | translate(x=-width/2, y=-width/2) def Petal_Fill(flower_type="JAMANTHI", side=50, petal_fill="yellow", petal_stroke="orange", columns=5): width = side d = width / columns xstart = width / 2 + d / 2 ystart = width / 2 + d / 2 shapes = [] for i in range(columns): for j in range(columns): x = -xstart + d * j y = ystart - d * i shape = Flower(fill=petal_fill, stroke=petal_stroke) | rotate(random(0, 360)) | translate(x=random(x-1, x+1), y=random(y-1, y+1)) shapes.append(shape) return combine(shapes) def flower_lines(flower="ROSE", fill="yellow", size=1, stroke="orange", width=50, divisions=5): dw = width / (divisions * size) shapes = [] for i in range(int(divisions + 1)): x = dw * i shape = Flower(type=flower, fill=fill, stroke=stroke) | rotate(random(0, 360)) | translate(x=x, y=0) | scale(size) shapes.append(shape) return combine(shapes) # CUSTOM POOGRID def custom_pooGrid(type="JAMANTHI", size=1, fill="white", stroke="grey"): c = Petal_Stroke_Square(flower_type="ROSE", columns=4, size=size, width=20, fill=fill, stroke=stroke) c1 = Flower(type=type, size=0.6, fill=fill, stroke=stroke) | scale(size) shape = c + c1 return shape | rotate(45) # USED TO GET APPROPRIATE FLOWER FOR POOKKALAM def Flower(type="ROSE", fill="white", stroke="lightgrey"): if type == "ROSE": return Rose(fill=fill, stroke=stroke) elif type == "JASMINE": return Jasmine(fill=fill, stroke=stroke) else: return Jamanthi(fill=fill, stroke=stroke) # ROSE def Rose(fill="tomato", stroke="red"): c1 = ellipse(w=15, h=10, fill=fill, stroke=stroke) | repeat(10, rotate(50) | scale(0.90)) return c1 # JASMINE def Jasmine(fill="white", stroke="lightgrey"): c1 = ellipse(w=15, h=5, fill=fill, stroke=stroke) | translate(x=10) | repeat(10, rotate(36)) c2 = circle(r=3, fill="yellow", stroke="orange") return c1 + c2 # JAMANTHI def Jamanthi(fill="#ffee00", stroke="#f0b400"): c1 = ellipse(w=8, h=3, fill=fill, stroke=stroke) | translate(x=5) | repeat(10, rotate(36)) c2 = c1 | scale(0.9) | rotate(15) c3 = c2 | scale(0.6) | rotate(15) shape = c1 + c2 + c3 return shape | rotate(random(0, 360)) # FILLS A CONTAINER WITH FLOWERS - SQUARE def Petal_Fill(flower_type, side, petal_fill, petal_stroke, columns): width = side d = int(width / columns) xstart = int(width / 2) - d / 2 ystart = int(width / 2 - d / 2) shapes = [] for i in range(columns): for j in range(columns): x = (-xstart) + int(d * j) y = ystart - int(d * i) shape = Flower(type=flower_type, fill=petal_fill, stroke=petal_stroke) | rotate(random(0, 360)) | translate(x=random(x-1, x+1), y=random(y-1, y+1)) shapes.append(shape) return combine(shapes) # TEST PROCESS POOKKALAM def getOuterPookkalam(): # OUTER STRUCTURE c1 = Petal_Stroke_Circle(flower="JAMANTHI", r=140, joints=7, angle=2, size=0.6, fill="yellow", stroke="orange") | rotate(0) | repeat(6, rotate(60)) c1_1 = Petal_Stroke_Circle(flower="JAMANTHI", r=140, joints=7, angle=2, size=0.6, fill="tomato", stroke="red") | rotate(30) | repeat(6, rotate(60)) c1_2 = Petal_Stroke_Circle(flower="JAMANTHI", r=140, joints=7, angle=2, size=0.6, fill="white", stroke="lightgrey") | rotate(15) | repeat(6, rotate(60)) c1_3 = Petal_Stroke_Circle(flower="JAMANTHI", r=140, joints=7, angle=2, size=0.6, fill="#07ad23", stroke="#015c10") | rotate(-15) | repeat(6, rotate(60)) b = Petal_Stroke_Circle(flower="JASMINE", r=150, joints=20, angle=20, size=0.3, fill="white", stroke="grey") | repeat(2, rotate(15)) outer0 = c1 + c1_1 + c1_2 + c1_3 | rotate(5) | repeat(5, rotate(15) | scale(0.95)) outer0 += b return outer0 def getInnerPookkalam(): c1 = Petal_Stroke_Circle(flower="JAMANTHI", r=47, joints=9, angle=7, size=0.5, fill="#07ad23", stroke="#017815") | rotate(12) | repeat(6, rotate(60)) return c1 # 3D KADHAKALI MASK COMPONENTS def greenface(): face = ellipse(w=90, h=120, fill="#208016", stroke="#208016") | translate(x=10, y=-10) face1 = ellipse(w=25, h=50, fill="#208016", stroke="#208016") | rotate(-10) | translate(x=-20, y=20) face2 = ellipse(w=30, h=65, fill="#208016", stroke="#208016") | rotate(18) | translate(x=-18, y=-33) face3 = ellipse(w=60, h=75, fill="#208016", stroke="#208016") | rotate(-55) | translate(x=19, y=-35) face4 = ellipse(w=60, h=75, fill="#208016", stroke="#208016") | rotate(-5) | translate(x=5, y=-35) return face + face1 + face2 + face3 + face4 | rotate(-2) def eyebrow(): e1 = ellipse(w=35, h=7, fill="black") | rotate(28) | translate(x=14, y=16) e2 = rectangle(w=12, h=7, fill="black") | rotate(-23) | translate(x=33, y=19) e3 = ellipse(w=20, h=5, fill="black") | rotate(30) | translate(x=8, y=5) return e1 + e2 + e3 def getKadhakali(): green_face = greenface() | repeat(3, rotate(120)) ebrow = eyebrow() | repeat(3, rotate(120)) # ADD other face details here in the same way for the mask return green_face + ebrow # UTILITY FUNCTION TO GENERATE RANDOM VALUES from random import randint def random(a, b): return randint(a, b)
Comments
Want to discuss?
Post it here, our mentors will help you out.
Login