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
Flag on the moon
By
Kaustubh Patil
Run
# night sky bg = rectangle(w=300, h=300, fill="#333333") show(bg) # stars star = circle(r=1, fill="#DDEEFF", stroke="none") import random random.seed(1337) for _ in range(50): x, y = random.randint(-150, 150), random.randint(-150, 150) show(star | translate(x=x, y=y)) moon = circle(x=0, y=-425, r=400, fill="#EEEEEE") show(moon) # flag flag_width = 150 flag_height = flag_width / 1.1 flag_section_height = flag_height / 3 ashoka_chakra_radius = flag_height / 10 def left_wave(h=25, w=50, fill="white", stroke="black"): x, y = -w / 2, 0 e = ellipse(x=x, y=y, w=w, h=h*2, fill=fill, stroke=stroke) r = rectangle(x=x, y=y-h/2, w=w, h=h, fill=fill, stroke="none") return e + r def right_wave(h=25, w=50, fill="white", stroke="black"): w = left_wave(h=h, w=w, fill=fill, stroke=stroke) return w | rotate(180) def left_flag_section(fill, stroke="none"): w = left_wave(w=100, h=33.3, fill=fill, stroke=stroke) r_lower = rectangle(w=100, h=33.3, y=-33.3/2, x=-50, fill=fill, stroke="none") return r_lower + w def right_flag_section(fill, stroke="none"): return left_flag_section(fill, stroke) | rotate(180) def flag(upper_bg, lower_bg): left_part = ( (left_flag_section("orange") | translate(y=flag_section_height * 2)) + (left_flag_section("white") | translate(y=flag_section_height)) + left_flag_section("green") + (left_flag_section(lower_bg) | translate(y=-flag_section_height))) right_part = ( (right_flag_section("green") | translate(y=-flag_section_height)) + right_flag_section("white") + (right_flag_section("orange") | translate(y=flag_section_height)) + (right_flag_section(upper_bg) | translate(y=flag_section_height * 2))) ashoka_outline = circle(r=ashoka_chakra_radius, stroke="blue") ashoka_spoke = line(x1=0, y1=0, x2=ashoka_chakra_radius, y2=0, stroke="blue") ashoka_spokes = ashoka_spoke | repeat(24, rotate(360/24)) ashoka = ashoka_outline + ashoka_spokes return left_part + ((right_part) | translate(y=18, x=-4)) + (ashoka | translate(y=30)) show(flag(upper_bg="#333333", lower_bg="#333333") | scale(0.2) | translate(y=25, x=20)) show(line(x1=0, y1=-25, x2=0, y2=52, stroke="#AAAAAA", stroke_width=3)) show(circle(r=2, y=52, fill="#CCCCCC", stroke="none"))
Comments
Want to discuss?
Post it here, our mentors will help you out.
Login