-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_title.py
executable file
·112 lines (97 loc) · 3.39 KB
/
make_title.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
"""
matplotlib playground to try to make slides
"""
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import os
import imageio.v2 as imageio
from colors import *
def make_title():
"""Makes the title slides"""
text_kwargs = dict(
family='sans-serif',
ha='center',
va='center',
fontsize=45,
color=BLACK,
wrap=True,
fontweight='semibold',
)
user = 'bsbanotto'
year = str(2023)
# Creating a 8 x 8 blank red screen
fig, ax = plt.subplots(figsize=(8, 8))
ax.set_aspect('equal')
# Scaling the axis to fill 100% of the figure
plt.gca().set_position([0, 0, 1, 1])
# Hiding the axes
ax.axis('off')
# Putting a bunch of circles on that screen
radius = .72
colors = [TEAL,
NAVY,
ORANGE,
GREY,
BLUE,
DARK_TEAL,
LIGHT_ORANGE,
]
for circles in range(0, 7):
circle = patches.Circle(xy=(.5, .5),
radius=radius,
color=colors[circles])
ax.add_patch(circle)
radius -= 0.05
# Create an offwhite starburst
center = (.5, .5)
height = 1
width = .50
pt1 = ((center[0] - (width / 2)), center[1])
pt2 = ((center[0] + (width / 2)), center[1])
pt3 = (center[0], height)
# Define the vertices of the isosceles triangle
vertices = np.array([pt1, pt2, pt3])
# Calculate the midpoint of the base
midpoint = (vertices[0] + vertices[1]) / 2.0
# Number of triangles to rotate
num_triangles = 18
# Calculate the rotation angle for each triangle
rot_ang = 360.0 / num_triangles
# Plot the original isosceles triangle
triangle = patches.Polygon(vertices,
closed=True,
edgecolor=WHITE,
facecolor=WHITE,
)
ax.add_patch(triangle)
# Rotate and plot the remaining triangles
for i in range(1, num_triangles):
# Rotate the vertices using a rotation matrix
rot_mat = np.array([[np.cos(
np.radians(i * rot_ang)
), -np.sin(np.radians(i * rot_ang))],
[np.sin(
np.radians(i * rot_ang)
), np.cos(np.radians(i * rot_ang))]])
rotated_vertices = np.dot(vertices - midpoint, rot_mat) + midpoint
# Plot the rotated triangle
rotated_triangle = patches.Polygon(rotated_vertices,
closed=True,
edgecolor=WHITE,
facecolor=WHITE,
)
ax.add_patch(rotated_triangle)
# Displaying lines of font with a pause between each one
plt.savefig(fname='png_files/0.png', format='png')
text1 = 'Welcome to ' + user + '\'s'
plt.text(.5, .73, text1, **text_kwargs)
plt.savefig(fname='png_files/1.png', format='png')
text2 = year
plt.text(.5, .565, text2, **text_kwargs)
plt.savefig(fname='png_files/2.png', format='png')
plt.text(.5, .435, 'GitHub', **text_kwargs)
plt.savefig(fname='png_files/3.png', format='png')
plt.text(.5, .295, 'Year in Review!', **text_kwargs)
plt.savefig(fname='png_files/4.png', format='png')