Code
import math
def sector(r, a, fill):
z = math.radians(a / 2)
y = r * math.cos(z)
x = r * math.sin(z)
return polygon(
[
point(0, 0),
point(x, y),
point(0, r),
point(-x, y),
],
fill=fill,
stroke="none",
)
def smooth_curve(points, depth=1):
def first_point(p_1, p_2):
new_p_1 = point(p_1.x * 3 / 4, p_1.y * 3 / 4)
new_p_2 = point(p_2.x * 1 / 4, p_2.y * 1 / 4)
return point(new_p_1.x + new_p_2.x, new_p_1.y + new_p_2.y)
def second_point(p_1, p_2):
new_p_1 = point(p_1.x * 1 / 4, p_1.y * 1 / 4)
new_p_2 = point(p_2.x * 3 / 4, p_2.y * 3 / 4)
return point(new_p_1.x + new_p_2.x, new_p_1.y + new_p_2.y)
# new_points = [points[0]]
new_points = [points[0]]
for i, _ in enumerate(points):
if i + 1 < len(points):
p_1 = points[i]
p_2 = points[i + 1]
q_point = first_point(p_1, p_2)
r_point = second_point(p_1, p_2)
new_points.append(q_point)
new_points.append(r_point)
else:
new_points.append(points[i])
if depth == 1:
return new_points
return smooth_curve(new_points, depth - 1)
def simple_petal(h, w, flag=True, **kwargs):
a = point(0, h)
b = point(w * 4 / 3, h / 2)
c = point(w, 0)
d = point(-w, 0)
e = point(-w * 4 / 3, h / 2)
f = a
points = [a, b, c, d, e, f]
if flag:
return polygon(smooth_curve(points, 4), **kwargs)
else:
return polygon(points)
colors = {
"black": "#09090B",
"dark_blue": "#3B3378",
"blue": "#7076B0",
"light_blue": "",
}
sector_colors = {
"dark_green": "#355543",
"green": "#546F37",
"white": "#C5CFB4",
"yellow": "#E5CA2D",
"dark_yellow": "#E8A112",
"orange": "#DE6209",
"red": "#9F2125",
"dark_red": "#641322",
"maroon": "#83132F",
"orange_red": "#D12D2D",
"pink": "#D61D60",
"light_pink": "#D995B3",
"blue": "#6A6FAE",
"dark_blue": "#474F98",
"indigo": "#3A3A77",
}
def color_function(color_dict):
for color in color_dict.values():
yield color
# Big Circle
# big_circle = circle(r=145,fill=colors["black"],stroke="none")
white_circle = circle(r=10, fill="white", stroke_width=1.5) # | scale(0.5)
r = 50
inner_circle = circle(r=r - 1, stroke_width=1.5)
sectors = None
angle = 360 / 15
count = 1
# c = color_function(sector_colors)
# sectors = sector(r, angle, random.choice(list(sector_colors.items()))) | repeat(len(sector_colors),rotate(angle))
# show(sectors)
for color in sector_colors.values():
if sectors is None:
sectors = sector(r, angle, color)
else:
sectors = combine([sectors, sector(50, angle, color) | rotate(-angle * count)])
count = count + 1
sectors = combine([sectors, inner_circle]) | scale(0.75)
black_circle = circle(r=45, fill="#0F1A1F")
# Simple Petal
simple_petal_colors = {
"red": "#840F2E",
"blue": "#38346F",
"purple": "#812257",
"orange": "#CB2D29",
}
simple_petals = None
count = 1
radius = 30
for i in range(2):
for color in simple_petal_colors.values():
petal = simple_petal(30, 10, fill=color) | scale(1.2) | translate(0, radius)
if simple_petals is None:
simple_petals = petal
else:
simple_petals = combine(
[
simple_petals,
petal | rotate(-360 / 8 * count),
]
)
count = count + 1
# Big petal
def big_petal(fill):
return combine(
[
simple_petal(60, 20, fill="#D3DFCB"),
simple_petal(60, 20, fill="#CBA912", stroke="none")
| scale(0.5)
| translate(-7, 23)
| repeat(2, translate(14)),
simple_petal(60, 20, fill="#D9870A", stroke="none")
| scale(0.5)
| translate(-13, 15)
| repeat(3, translate(13)),
simple_petal(60, 20, fill="#DF5D12", stroke="none")
| scale(0.5)
| translate(-18, 8)
| repeat(4, translate(12)),
simple_petal(60, 20, fill="#A12928", stroke="none")
| scale(0.5)
| translate(-12, 0)
| repeat(3, translate(12)),
simple_petal(60, 20, fill=fill) | scale(0.5),
simple_petal(60, 20, fill="tranparent"),
]
)
big_petal_colors = {
"peach": "#D098B3",
"blue": "#7489CA",
"pink": "#D02359",
"red": "#941123",
}
big_petals = None
count = 1
radius = 33
for i in range(2):
for color in big_petal_colors.values():
petal = big_petal(fill=color) | translate(0, radius)
if big_petals is None:
big_petals = petal
else:
big_petals = combine(
[
big_petals,
petal | rotate(-360 / 8 * count),
]
)
count = count + 1
big_petals = big_petals | rotate(23)
# show(big_petal)
# Medium circle
medium_circle = combine(
[
circle(r=95, fill="#2E2B66"),
circle(r=85, fill="#6978BD", stroke="None"),
circle(r=75, fill="#D1D2CF", stroke="None"),
]
)
gradient = [
"#FFFFFF",
"#FFBA08",
"#FAA307",
"#F48C06",
"#E85D04",
"#DC2F02",
"#D00000",
]
fire = combine(
[
simple_petal(60, 20, stroke="none", fill=color) | scale(i * 0.3)
for i, color in enumerate(gradient)
][::-1]
)
fires = fire | scale(0.5) | translate(0, 83) | rotate(50) | repeat(30, rotate(360 / 30))
# show(s)
con_circle = combine(
[
circle(r=50, fill="red", stroke="none"),
circle(r=37, fill="orange", stroke="none"),
circle(r=21, fill="white", stroke="none"),
]
)
con_circles = con_circle | translate(90) | repeat(10,rotate(360/10))
# show(con_circle)
big_circle = circle(r=145)
pookalam = combine(
[
# big_circle,
# con_circles,
# fires,
medium_circle,
big_petals,
black_circle,
simple_petals,
sectors,
white_circle,
]
) | scale(1.5)
show(pookalam)