Code
import math
#utils
# return a point on ellipse at angle theta of ellipse with specified height and width
def part_of_ellipse(w,h,theta):
return point(math.sin(theta)*(w),math.cos(theta)*(h))
#function to draw curve
#Params: width, height of ellipse and part of the ellipse (like 0.5- semi ellipse)
#returns: list of points forming that curve
def segment_of_ellipse(w,h,part):
points = []
step = 0.01
i = 0
while i < (3.14*(part*2)):
points.append(part_of_ellipse(w,h,i))
i = i+step
return points
# outer layer consists of a white circle with black stroke 20px wide.
# small white circles sourrounding it.
c1 = circle(r=5,fill="white") | translate(x=140)| repeat(36, rotate(10))
c2 = circle(r=140,fill="#fbff7a", stroke="black", stroke_width=20)
outer_layer = combine([c2+c1])
#middle layer
r1 = rectangle(h=10, w=10, fill="yellow", stroke="none") | rotate(45)|translate(y=110)
r2 = rectangle(h=20, w=20, fill="green", stroke="none") | rotate(45) |translate(y=110)
diamond = combine([r2, r1]) | rotate(30) | repeat(6, rotate(60))
e1=ellipse(h=245,w=125,fill="black",stroke="none")|repeat(6,rotate(60))
e2=ellipse(h=230,w=110,fill="#880627",stroke="none")|repeat(6,rotate(60))
e3=ellipse(h=215,w=95,fill="red",stroke="none")|repeat(6,rotate(60))
e4=ellipse(h=200,w=80,fill="orange",stroke="none")|repeat(6,rotate(60))
e5=ellipse(h=185,w=65,fill="yellow",stroke="none")|repeat(6,rotate(60))
e6=ellipse(h=170,w=50,fill="white",stroke="none")|repeat(6,rotate(60))
middle_layer = combine([e1, e2, e3,e4, e5, e6, diamond])
#inner layer
c3 = circle(r=128, fill="white", stroke_width=3)
#a combination of lines varying slightly in color
gradient_line = line(x1=0, y1=0, x2=0, y2=0)
for i in range(254):
line_color = color(r=255, g=i, b=0)
if i<127:
gradient_line += line(x1=i-127, y1=i, x2=i-127, y2=-i, stroke=line_color)
else:
gradient_line += line(x1=i-127, y1=254-i, x2=i-127, y2=-(254-i), stroke=line_color)
p1 = point(x=0, y=0)
p2 = point(x=-50, y=50)
p3 = point(x=0, y=100)
p4 = point(x=30, y=70.71)
p5 = point(x=0, y=70.71)
overlapping_squares= polygon([p1, p2, p3,p4, p5], fill="red", stroke="white", stroke_width=5) |repeat(8, rotate(45))|scale(0.9)
segment1 = polygon(segment_of_ellipse(120, 120, 0.20),fill="#025e05", stroke="none") | rotate(-9) | repeat(4, rotate(90))
inner_layer = combine([c3 , gradient_line, overlapping_squares,segment1])|scale(0.5)
show(outer_layer+middle_layer+inner_layer)