<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>christmas | B101nfo</title>
    <link>https://llrs.dev/tags/christmas/</link>
      <atom:link href="https://llrs.dev/tags/christmas/index.xml" rel="self" type="application/rss+xml" />
    <description>christmas</description>
    <generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>If it is code you can copy and reuse (MIT) if it is text, please cite and reuse CC-BY 2024.</copyright><lastBuildDate>Wed, 18 Dec 2019 00:00:00 +0000</lastBuildDate>
    <image>
      <url>img/map[gravatar:%!s(bool=false) shape:circle]</url>
      <title>christmas</title>
      <link>https://llrs.dev/tags/christmas/</link>
    </image>
    
    <item>
      <title>Christmas tree</title>
      <link>https://llrs.dev/post/2019/12/18/christmas-tree/</link>
      <pubDate>Wed, 18 Dec 2019 00:00:00 +0000</pubDate>
      <guid>https://llrs.dev/post/2019/12/18/christmas-tree/</guid>
      <description>
&lt;script src=&#34;https://llrs.dev/post/2019/12/18/christmas-tree/index_files/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;


&lt;p&gt;So it is Christmas and I want a tree. I found this new package experimental &lt;a href=&#34;https://github.com/thomasp85/ggfx&#34;&gt;ggfx&lt;/a&gt; and I thought it would be nice to use it for the lights.
Then some time later I found (through twitter) this &lt;a href=&#34;https://github.com/r-link/christmas_tree_challenge&#34;&gt;other repo&lt;/a&gt; about building trees.&lt;/p&gt;
&lt;p&gt;So here I am building my own christmas tree!&lt;/p&gt;
&lt;div id=&#34;the-very-basics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;The very basics&lt;/h1&gt;
&lt;p&gt;We start with installations:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devtools::install_github(&amp;#39;thomasp85/ggfx&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We’ll build our tree with triangles:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(&amp;quot;ggplot2&amp;quot;)
ggplot(data.frame(x = c(-5, 5, 0), y = c(0, 0, 5))) +
  geom_polygon(aes(x, y), fill = &amp;quot;green&amp;quot;) +
  theme_void()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://llrs.dev/post/2019/12/18/christmas-tree/index_files/figure-html/triangle-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To make it easier we use some functions for the triangles:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;iso_triangle &amp;lt;- function(wide, height, xvertix, yvertix) {
  y &amp;lt;- c(rep(yvertix-height, 2), yvertix)
  x &amp;lt;- c(xvertix+wide/2, xvertix-wide/2, xvertix)
  data.frame(x, y)
}

square &amp;lt;- function(length, x_bottom_right, y_bottom_right) {
  x &amp;lt;- rep(c(x_bottom_right-length, x_bottom_right), 2)
  y &amp;lt;- rep(c(y_bottom_right, y_bottom_right+length), each = 2)
  data.frame(x, y)[c(1, 3, 4, 2), ]
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And off to build a tree:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tree &amp;lt;- ggplot() +
  aes(x, y) +
  geom_polygon(data = square(0.5, 0.25, 0.25), fill = &amp;quot;brown&amp;quot;) +
  geom_polygon(data = iso_triangle(10, 4, 0, 4.5), fill = &amp;quot;darkgreen&amp;quot;) + 
  geom_polygon(data = iso_triangle(9, 4, 0, 4.5), fill = &amp;quot;lightgreen&amp;quot;) + 
  geom_polygon(data = iso_triangle(8, 3, 0, 6), fill = &amp;quot;green&amp;quot;) +
  geom_polygon(data = iso_triangle(7, 3, 0, 6), fill = &amp;quot;darkgreen&amp;quot;) +
  geom_polygon(data = iso_triangle(6, 2.5, 0, 7), fill = &amp;quot;lightgreen&amp;quot;) + 
  geom_polygon(data = iso_triangle(5, 2.5, 0, 7), fill = &amp;quot;green&amp;quot;) + 
  geom_polygon(data = iso_triangle(4, 1.5, 0, 7.5), fill = &amp;quot;darkgreen&amp;quot;) +
  geom_polygon(data = iso_triangle(3, 1.5, 0, 7.5), fill = &amp;quot;lightgreen&amp;quot;) +
  geom_polygon(data = iso_triangle(2, 1.5, 0, 8), fill = &amp;quot;green&amp;quot;)
tree&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://llrs.dev/post/2019/12/18/christmas-tree/index_files/figure-html/tree-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;The tree looks good enough, but if you disagree or want some more realistic trees see &lt;a href=&#34;https://github.com/r-link/christmas_tree_challenge&#34;&gt;this challenge&lt;/a&gt;.
Very funny to play with it (but I didn’t manage to build my tree with it :/).
Anyway, now we have the tree and we need to turn them to a glowing tree!!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;decorating-the-tree&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Decorating the tree&lt;/h1&gt;
&lt;p&gt;Now it is time to decorate and turn on the lights with the help of ggfx:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(&amp;quot;ggfx&amp;quot;)
tree + 
  with_blur(geom_point(data =data.frame(x = 0, y = 8), size = 3, col = &amp;quot;yellow&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = c(2, -3), y = c(1.5, 1)), size = 3, col = &amp;quot;darkgreen&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = c(2, -3), y = 2.5+c(1, 1.2)), size = 3, col = &amp;quot;purple&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = -5, y = 0.5), size = 3, col = &amp;quot;red&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = 5, y = 0.5), size = 3, col = &amp;quot;orange&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = -2.5, y = 4), size = 3, col = &amp;quot;red&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = 3, y = 3.5), size = 3, col = &amp;quot;black&amp;quot;), sigma = 2, stack = TRUE) + 
  with_blur(geom_point(data =data.frame(x = c(-1, 1.25), y = c(5, 5.5)), size = 3, col = &amp;quot;orange&amp;quot;), sigma = 2, stack = TRUE) + 
  theme_void() +
  theme(plot.background = element_rect(fill = &amp;quot;black&amp;quot;)) +
  NULL&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://llrs.dev/post/2019/12/18/christmas-tree/index_files/figure-html/decorating-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;And now we have our Christmas tree decorated!&lt;/p&gt;
&lt;p&gt;Happy Christmas!!&lt;/p&gt;
&lt;div id=&#34;reproducibility&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reproducibility&lt;/h3&gt;
&lt;details&gt;
&lt;pre&gt;&lt;code&gt;## ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
##  setting  value                       
##  version  R version 4.0.1 (2020-06-06)
##  os       Ubuntu 20.04.1 LTS          
##  system   x86_64, linux-gnu           
##  ui       X11                         
##  language (EN)                        
##  collate  en_US.UTF-8                 
##  ctype    en_US.UTF-8                 
##  tz       Europe/Madrid               
##  date     2021-01-08                  
## 
## ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
##  package     * version    date       lib source                           
##  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.1)                   
##  blogdown      0.21.84    2021-01-07 [1] Github (rstudio/blogdown@c4fbb58)
##  bookdown      0.21       2020-10-13 [1] CRAN (R 4.0.1)                   
##  cli           2.2.0      2020-11-20 [1] CRAN (R 4.0.1)                   
##  colorspace    2.0-0      2020-11-11 [1] CRAN (R 4.0.1)                   
##  crayon        1.3.4      2017-09-16 [1] CRAN (R 4.0.1)                   
##  digest        0.6.27     2020-10-24 [1] CRAN (R 4.0.1)                   
##  dplyr         1.0.2      2020-08-18 [1] CRAN (R 4.0.1)                   
##  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.0.1)                   
##  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.1)                   
##  fansi         0.4.1      2020-01-08 [1] CRAN (R 4.0.1)                   
##  farver        2.0.3      2020-01-16 [1] CRAN (R 4.0.1)                   
##  generics      0.1.0      2020-10-31 [1] CRAN (R 4.0.1)                   
##  ggfx        * 0.0.0.9000 2020-08-20 [1] Github (thomasp85/ggfx@4345c5e)  
##  ggplot2     * 3.3.2      2020-06-19 [1] CRAN (R 4.0.1)                   
##  glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.1)                   
##  gtable        0.3.0      2019-03-25 [1] CRAN (R 4.0.1)                   
##  htmltools     0.5.0      2020-06-16 [1] CRAN (R 4.0.1)                   
##  knitr         1.30       2020-09-22 [1] CRAN (R 4.0.1)                   
##  labeling      0.4.2      2020-10-20 [1] CRAN (R 4.0.1)                   
##  lifecycle     0.2.0      2020-03-06 [1] CRAN (R 4.0.1)                   
##  magick        2.5.2      2020-11-10 [1] CRAN (R 4.0.1)                   
##  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.0.1)                   
##  munsell       0.5.0      2018-06-12 [1] CRAN (R 4.0.1)                   
##  pillar        1.4.7      2020-11-20 [1] CRAN (R 4.0.1)                   
##  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.1)                   
##  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.1)                   
##  R6            2.5.0      2020-10-28 [1] CRAN (R 4.0.1)                   
##  ragg          0.4.0      2020-10-05 [1] CRAN (R 4.0.1)                   
##  Rcpp          1.0.5      2020-07-06 [1] CRAN (R 4.0.1)                   
##  rlang         0.4.10     2020-12-30 [1] CRAN (R 4.0.1)                   
##  rmarkdown     2.6        2020-12-14 [1] CRAN (R 4.0.1)                   
##  scales        1.1.1      2020-05-11 [1] CRAN (R 4.0.1)                   
##  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.1)                   
##  stringi       1.5.3      2020-09-09 [1] CRAN (R 4.0.1)                   
##  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.0.1)                   
##  systemfonts   0.3.2      2020-09-29 [1] CRAN (R 4.0.1)                   
##  textshaping   0.2.1      2020-11-13 [1] CRAN (R 4.0.1)                   
##  tibble        3.0.4      2020-10-12 [1] CRAN (R 4.0.1)                   
##  tidyselect    1.1.0      2020-05-11 [1] CRAN (R 4.0.1)                   
##  vctrs         0.3.6      2020-12-17 [1] CRAN (R 4.0.1)                   
##  withr         2.3.0      2020-09-22 [1] CRAN (R 4.0.1)                   
##  xfun          0.20       2021-01-06 [1] CRAN (R 4.0.1)                   
##  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.1)                   
## 
## [1] /home/lluis/bin/R/4.0.1/lib/R/library&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>
