Made using ggplot2, gganimate and a cardioid polar equation.
library(dplyr)
library(tidyr)
library(broom)
library(ggplot2)
library(gganimate)
d <- data_frame(t = seq(-pi, 0, .01),
x1 = 16 * (sin(t)) ^ 2,
x2 = -x1,
y = 13 * cos(t) -
5 * cos(2 * t) -
2 * cos(3 * t) -
cos(4 * t)) %>%
gather(side, x, x1, x2)
heart <- d %>%
inflate(t1 = max(d$t) + seq_len(20)) %>%
arrange(((side == "x2") - 1) * t)
g <- ggplot(d, aes(x, y, frame = round(t, 1))) +
geom_path(aes(cumulative = TRUE, group = side)) +
geom_polygon(aes(alpha = t1, frame = t1), data = heart, fill = "red", show.legend = FALSE) +
geom_text(aes(x = 0, y = 0, label = "Happy Valentine's Day", alpha = t1, frame = t1),
data = heart, size = 8, color = "white", show.legend = FALSE) +
coord_equal() +
theme_bw()
s <- gg_animate(g, interval = .1,
title_frame = FALSE)
s