# Merry ChRistmas!

**Revolutions**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Christmas day is soon upon us, so here's a greeting made with R:

Each frame is a Voronoi Tesselation: about 1,000 points are chosen across the plane, which each generate a polygon comprising the region closer to it than any other selected point. These process is repeated for three designs (a heart, the word “Merry”, and the word “Xmas”), and the Voronoi tiles are colored according to whether the generating point is within the design. In the transitions between the designs, the points migrate from one selected point in one design to a selected counterpoint in the next. The counterpoint is randomly chosen for the “heart” transition (generating a chaotic assembly effect); and a nearby point is chosen for the “Merry” transition (for a much smoother effect).

There's some interesting R-based magic behind how the animation was created as well. The three designs were created in Adobe Illustrator. Getting shapes from Illustrator into R is a surprisingly simple two-line process: you simply import the design using fromJSON, and extract the component representing line segments which can be immediately drawn in R. The tesselations were drawn using the `geom_voronoi_tile()`

ggplot2 geom in the Github version of the ggforce package, and colored by checking whether the generating point falls inside the design using the `in.out`

function of the mgcv package. The smooth transition of the generating points from one design to the next were calculated using the tweenr package, and the whole thing was animated using the animation package.

For the complete details on how this lovely greeting was created, including the R code, follow the link to creator Thomas Lin Pedersen's blog post below.

Data Imaginist: Data Driven Christmas Card Animation with Voronoi Tiles

**leave a comment**for the author, please follow the link and comment on their blog:

**Revolutions**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.