-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro.py
97 lines (72 loc) · 2.87 KB
/
intro.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
import sys
from PIL import Image, ImageDraw, ImageFont
from moviepy.editor import ImageSequenceClip
from statics.helpers import DrawHelpers
FRAME_COLOR_1 = '#EE1D52'
FRAME_COLOR_2 = '#69C9D0'
FONT_COLOR = '#ffffff'
BACKGROUND = '#010101'
FONT_PATH = './statics/fonts/montserrat.ttf'
IMAGE_SIZE = (WIDTH, HEIGHT) = (1080, 1920)
def get_powered_by():
return Image.open('./statics/logos/powered.png').convert('RGBA')
def get_logo_tech(tech):
return Image.open(f'./statics/logos/{tech}.png').convert('RGBA')
largura = WIDTH
altura = HEIGHT
fps = 30
tempo_total = 6
quadros = []
# Declarando a fonte
font = ImageFont.truetype(FONT_PATH, 80)
texto = sys.argv[1]
texto = texto.upper()
lether_list = []
for l in texto:
lether_list.append(l)
lether_list = lether_list[::-1]
lether_time = ((fps*tempo_total) // (len(texto)+6))
animation_text = []
count = 0
logo = get_powered_by()
width_logo, height_logo = logo.size
for tempo in range(tempo_total * fps):
if count>lether_time:
count=0
try:
animation_text.append(lether_list.pop())
except:
pass
print(animation_text)
image = Image.new('RGBA', IMAGE_SIZE, BACKGROUND)
draw = ImageDraw.Draw(image)
frame_1_start = ((HEIGHT//2)-100)-100
frame_1_end = ((HEIGHT//2)-100)
draw.rectangle((frame_1_start-550,frame_1_start,frame_1_end-550,frame_1_end), FRAME_COLOR_1)
draw.rectangle((frame_1_start-500,frame_1_start+50,frame_1_end-450,frame_1_end+100), BACKGROUND)
draw.rectangle((frame_1_start,frame_1_start,frame_1_end,frame_1_end), FRAME_COLOR_2)
draw.rectangle((frame_1_start-50,frame_1_start+50,frame_1_end-50,frame_1_end+50), BACKGROUND)
draw.rectangle((frame_1_start, frame_1_start+350, frame_1_end, frame_1_end+350), FRAME_COLOR_1)
draw.rectangle((frame_1_start-50,frame_1_start+300,frame_1_end-50,frame_1_end+300), BACKGROUND)
draw.rectangle((frame_1_start-550,frame_1_start+350,frame_1_end-550,frame_1_end+350), FRAME_COLOR_2)
draw.rectangle((frame_1_start-500,frame_1_start+300,frame_1_end-500,frame_1_end+300), BACKGROUND)
# total arguments
if (animation_text):
text_width, text_height = DrawHelpers.get_text_dimensions(''.join(animation_text), font)
POSITION = (((WIDTH//2)-(text_width//2)), ((HEIGHT//2)-(text_height//2)))
draw.text(
POSITION,
''.join(animation_text),
font=font,
fill=FONT_COLOR
)
# Adicione o quadro à lista
count += 1
image.save(f"./build/{''.join(animation_text)}_{count}.png")
quadros.append(f"./build/{''.join(animation_text)}_{count}.png")
print(f'Total de quadros: {len(quadros)}')
print(f'Termpo por letra: {lether_time}')
print(f'texto: {lether_list}')
print(f'len_texto: {len(lether_list)}')
video = ImageSequenceClip(quadros, fps=fps)
video.write_videofile(f'intro{texto}.mp4', fps=fps)