rm(list = ls())
#install.packages("ggthemes")
library(ggplot2)
################
#heart data
t = seq(0, 2 * pi, by = 0.1)
x = 16 * sin(t)^3
y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)
a = (x - min(x))/(max(x) - min(x))
b = (y - min(y))/(max(y) - min(y))
heartd <- data.frame(t,x,y,a,b)
###plot
ggplot(heartd,aes(a,b)) +geom_path(color="red",size=2) +
theme(panel.background = element_blank(),
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank()) +
geom_polygon(fill="pink") +
annotate("text",label= "T-A-Y", x= 0.5,y = 0.5,color = "red",size = 15)

###############################
library(grid)
# heart function
heart <- function(lcolor) {
t = seq(0, 2 * pi, by = 0.1)
x = 16 * sin(t)^3
y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)
a = (x - min(x))/(max(x) - min(x))
b = (y - min(y))/(max(y) - min(y))
grid.lines(a, b, gp = gpar(col = lcolor, lty = "solid", lwd = 3))
}
#pattern
grid.newpage()
vp1 <- viewport(0.4, 0.5, w = 0.5, h = 0.5, angle = 15)
pushViewport(vp1)
heart("red")
vp2 <- viewport(0.9, 0.27, w = 0.7, h = 0.7, angle = -30)
pushViewport(vp2)
heart("hotpink")
grid.text("Happy valentine's day!", x = 0.2, y = 1.2,
just = c("center", "bottom"), gp = gpar(fontsize = 15,col="red"))
