Update and rename README.md to Mary - #104
Open
eg707626-collab wants to merge 1 commit into
Open
Conversation
# ============================================
# ❤️ VIDEO PARA MARY - TIKTOK / LIKEE ❤️
# ============================================
!pip -q install moviepy pillow
import random
import math
from PIL import Image, ImageDraw, ImageFont
from moviepy import VideoClip
from google.colab import files
ANCHO = 1080
ALTO = 1920
DURACION = 12
FPS = 30
FUENTE_GRANDE = ImageFont.truetype(
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 110
)
FUENTE_MEDIANA = ImageFont.truetype(
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 65
)
corazones = []
for i in range(40):
corazones.append({
"x": random.randint(30, ANCHO - 30),
"y": random.randint(0, ALTO),
"velocidad": random.randint(50, 130),
"tamano": random.randint(20, 55)
})
def dibujar_corazon(draw, x, y, tamano):
puntos = []
for i in range(101):
t = 2 * math.pi * i / 100
px = 16 * math.sin(t) ** 3
py = -(13 * math.cos(t)
- 5 * math.cos(2*t)
- 2 * math.cos(3*t)
- math.cos(4*t))
puntos.append((
x + px * tamano / 20,
y + py * tamano / 20
))
draw.polygon(
puntos,
fill=(255, 70, 150)
)
def texto_centrado(draw, texto, fuente, y):
caja = draw.textbbox(
(0, 0),
texto,
font=fuente
)
ancho = caja[2] - caja[0]
x = (ANCHO - ancho) / 2
draw.text(
(x + 6, y + 6),
texto,
font=fuente,
fill=(80, 0, 50)
)
draw.text(
(x, y),
texto,
font=fuente,
fill=(255, 255, 255)
)
def crear_frame(t):
img = Image.new(
"RGB",
(ANCHO, ALTO),
(15, 3, 25)
)
draw = ImageDraw.Draw(img)
# Estrellas
random.seed(10)
for i in range(120):
x = random.randint(0, ANCHO)
y = random.randint(0, ALTO)
draw.ellipse(
(x, y, x + 4, y + 4),
fill=(150, 70, 130)
)
# Corazones flotando
for c in corazones:
y = (
c["y"]
- c["velocidad"] * t
) % ALTO
dibujar_corazon(
draw,
c["x"],
y,
c["tamano"]
)
# Texto del video
if t < 3:
texto_centrado(
draw,
"❤️ MARY ❤️",
FUENTE_GRANDE,
700
)
elif t < 6:
texto_centrado(
draw,
"Tengo algo",
FUENTE_MEDIANA,
650
)
texto_centrado(
draw,
"que decirte...",
FUENTE_MEDIANA,
750
)
elif t < 9:
texto_centrado(
draw,
"❤️ TE QUIERO ❤️",
FUENTE_GRANDE,
700
)
else:
texto_centrado(
draw,
"MARY ✨",
FUENTE_GRANDE,
650
)
texto_centrado(
draw,
"Eres muy especial ❤️",
FUENTE_MEDIANA,
800
)
return img
def frame(t):
return crear_frame(t)
print("🎬 Creando video para MARY...")
print("⏳ Espera mientras se genera...")
video = VideoClip(
frame_function=frame,
duration=DURACION
)
video = video.with_fps(FPS)
archivo = "/content/Mary_Te_Quiero.mp4"
video.write_videofile(
archivo,
fps=FPS,
codec="libx264",
audio=False
)
print("\n❤️ ¡VIDEO TERMINADO! ❤️")
files.download(archivo)
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
============================================
❤️ VIDEO PARA MARY - TIKTOK / LIKEE ❤️
============================================
!pip -q install moviepy pillow
import random
import math
from PIL import Image, ImageDraw, ImageFont
from moviepy import VideoClip
from google.colab import files
ANCHO = 1080
ALTO = 1920
DURACION = 12
FPS = 30
FUENTE_GRANDE = ImageFont.truetype(
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 110
)
FUENTE_MEDIANA = ImageFont.truetype(
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 65
)
corazones = []
for i in range(40):
corazones.append({
"x": random.randint(30, ANCHO - 30),
"y": random.randint(0, ALTO),
"velocidad": random.randint(50, 130),
"tamano": random.randint(20, 55)
})
def dibujar_corazon(draw, x, y, tamano):
puntos = []
def texto_centrado(draw, texto, fuente, y):
def crear_frame(t):
def frame(t):
return crear_frame(t)
print("🎬 Creando video para MARY...")
print("⏳ Espera mientras se genera...")
video = VideoClip(
frame_function=frame,
duration=DURACION
)
video = video.with_fps(FPS)
archivo = "/content/Mary_Te_Quiero.mp4"
video.write_videofile(
archivo,
fps=FPS,
codec="libx264",
audio=False
)
print("\n❤️ ¡VIDEO TERMINADO! ❤️")
files.download(archivo)