class: center, middle, inverse, title-slide #
anicon
R package ## Animated icons for R markdown and Shiny ### Emi Tanaka ### 2018/07/24 --- # Getting Started ```r anicon::faa("leaf") ```
<i class="fas fa-leaf faa-flash animated "></i>
### Let's try bouncing ```r anicon::faa("leaf", animate="bounce") ```
<i class="fas fa-leaf faa-bounce animated "></i>
### Or embedding the icon inline
<i class="fas fa-leaf faa-burst animated "></i>
can be embedded by enclosing <code>r anicon::faa("leaf", animate="burst")</code> by back ticks. ??? including via trick here https://stackoverflow.com/questions/20409172/how-to-display-verbatim-inline-r-code-with-backticks-using-rmarkdown doesn't work with table with r commands. "doesn't work" = --- doesn't start a new slide. --- ## Here's the list of all available animation `anicon` | `animate` | `anicon` | `animate` --- | --- | --- | ---
<i class="fas fa-leaf fa-lg faa-burst animated "></i>
| `burst` |
<i class="fas fa-leaf fa-lg faa-pulse animated "></i>
| `pulse`
<i class="fas fa-leaf fa-lg faa-bounce animated "></i>
| `bounce` |
<i class="fas fa-leaf fa-lg faa-ring animated "></i>
| `ring`
<i class="fas fa-leaf fa-lg faa-falling animated "></i>
| `falling` |
<i class="fas fa-leaf fa-lg faa-shake animated "></i>
| `shake`
<i class="fas fa-leaf fa-lg faa-flash animated "></i>
| `flash` |
<i class="fas fa-leaf fa-lg faa-spin animated "></i>
| `spin`
<i class="fas fa-leaf fa-lg faa-float animated "></i>
| `float` |
<i class="fas fa-leaf fa-lg faa-spin-reverse animated "></i>
| `spin-reverse`
<i class="fas fa-leaf fa-lg faa-horizontal animated "></i>
| `horizontal` |
<i class="fas fa-leaf fa-lg faa-tada animated "></i>
| `tada`
<i class="fas fa-leaf fa-lg faa-passing animated "></i>
| `passing` |
<i class="fas fa-leaf fa-lg faa-vertical animated "></i>
| `vertical`
<i class="fas fa-leaf fa-lg faa-passing-reverse animated "></i>
| `passing-reverse` |
<i class="fas fa-leaf fa-lg faa-wrench animated "></i>
| `wrench` --- ## Here's a more colourful list of all available animation `anicon` | `animate` | `anicon` | `animate` --- | --- | --- | ---
<i class="fas fa-bomb fa-lg faa-burst animated " style=" color:blue;"></i>
| `burst` |
<i class="fas fa-heart fa-lg faa-pulse animated " style=" color:#CC263C;"></i>
| `pulse`
<i class="fas fa-basketball-ball fa-lg faa-bounce animated " style=" color:orange;"></i>
| `bounce` |
<i class="fas fa-bell fa-lg faa-ring animated " style=" color:gold;"></i>
| `ring`
<i class="fas fa-leaf fa-lg faa-falling animated " style=" color:green;"></i>
| `falling` |
<i class="fas fa-gavel fa-lg faa-shake animated " style=" color:purple;"></i>
| `shake`
<i class="fas fa-exclamation-triangle fa-lg faa-flash animated " style=" color:red;"></i>
| `flash` |
<i class="fas fa-futbol fa-lg faa-spin animated "></i>
| `spin`
<i class="fab fa-twitter fa-lg faa-float animated " style=" color:#1DA1F2;"></i>
| `float` |
<i class="fas fa-bowling-ball fa-lg faa-spin-reverse animated " style=" color:#2c42ae;"></i>
| `spin-reverse`
<i class="fas fa-hand-point-right fa-lg faa-horizontal animated " style=" color:#a8a8db;"></i>
| `horizontal` |
<i class="fas fa-trophy fa-lg faa-tada animated " style=" color:#eaea3c;"></i>
| `tada`
<i class="fas fa-caret-square-right fa-lg faa-passing animated " style=" color:#C7ABC8;"></i>
| `passing` |
<i class="fas fa-thumbs-up fa-lg faa-vertical animated " style=" color:#3B5998;"></i>
| `vertical`
<i class="fas fa-caret-square-left fa-lg faa-passing-reverse animated " data-fa-transform="flip-v " style=" color:#a8a8db;"></i>
| `passing-reverse` |
<i class="fas fa-wrench fa-lg faa-wrench animated " style=" color:#808080;"></i>
| `wrench` --- # Let's change the speed of the animation ```r anicon::faa("leaf", animate="bounce") ```
<i class="fas fa-leaf faa-bounce animated "></i>
### Go faster ```r anicon::faa("leaf", animate="bounce", speed="fast") ```
<i class="fas fa-leaf faa-bounce animated faa-fast "></i>
### Go slower ```r anicon::faa("leaf", animate="bounce", speed="slow") ```
<i class="fas fa-leaf faa-bounce animated faa-slow "></i>
--- # Let's grow it.. ```r anicon::faa("leaf", size=2, bgcolour="MistyRose", colour="green") ```
<i class="fas fa-leaf fa-2x faa-flash animated " style=" color:green; background:MistyRose;"></i>    the container grows with it
```r anicon::faa("leaf", grow=20, bgcolour="MistyRose", colour="green") ```
<i class="fas fa-leaf faa-flash animated " data-fa-transform="grow-20 " style=" color:green; background:MistyRose;"></i>      the container doesn't change
```r anicon::faa("leaf", grow=-2, bgcolour="MistyRose", colour="green") ```
<i class="fas fa-leaf faa-flash animated " data-fa-transform="shrink-20 " style=" color:green; background:MistyRose;"></i>      negative values will shrink it
--- # Changing position of the icon ```r anicon::faa("magic", size=4, bgcolour="red", colour="pink", position=c(3, 0, 3, 0)) ```
<i class="fas fa-magic fa-4x faa-flash animated " data-fa-transform="up-3 left-3 " style=" color:pink; background:red;"></i>
```r anicon::faa("magic", size=4, bgcolour="red", colour="pink", position=c(0, 3, 3, 0)) ```
<i class="fas fa-magic fa-4x faa-flash animated " data-fa-transform="down-3 left-3 " style=" color:pink; background:red;"></i>
<br><br><br> Position is given as vector of length 4 specifying up, down, left and right, respectively. --- # Hovering to trigger animation ### Try hovering over the icon ```r anicon::faa("pagelines", size=3, colour="purple", animate="wrench", anitype="hover", rtext="Hi there!") ```
<i class="fab fa-pagelines fa-3x faa-wrench animated-hover " style=" color:purple;"></i>Hi there!
### Now try hovering over the text this time ```r anicon::faa("pagelines", size=3, colour="purple", animate="wrench", anitype="parent-hover", rtext="Hi there!") ```
<i class="fab fa-pagelines fa-3x faa-wrench " style=" color:purple;"></i>Hi there!
--- # You can embed these into Shiny It works in shiny by using say `tags$p(anicon::faa("child"))`. Below is a working example, ```r ui <- fluidPage( titlePanel(tags$p(anicon::faa("child"), "Old Faithful Geyser Data")), sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50,value = 30) ), mainPanel( plotOutput("distPlot")) ) ) server <- function(input, output) { output$distPlot <- renderPlot({ ggplot(faithful, aes(waiting)) + geom_histogram(bins=input$bins) + theme_bw() }) } ``` --- # Other features ```r anicon::faa("magic", size=2, colour="blue", rotate=45, rtext=" rotate") ```
<i class="fas fa-magic fa-2x faa-flash animated " data-fa-transform="rotate-45 " style=" color:blue;"></i> rotate
```r anicon::faa("magic", size=2, colour="blue", flip="vertical", rtext=" flip it vertically") ```
<i class="fas fa-magic fa-2x faa-flash animated " data-fa-transform="flip-v " style=" color:blue;"></i> flip it vertically
```r anicon::faa("magic", size=2, colour="blue", border=T, rtext=" put a border around it") ```
<i class="fas fa-magic fa-2x faa-flash animated fa-border" style=" color:blue;"></i> put a border around it
--- # `anicon` also has animated text! ```r anicon::nia("Yes that's right!") ```
Yes that's right!
`anicon` | `anicon` --- | ---
burst
|
pulse
bounce
|
ring
fallling
|
shake
flash
|
spin
float
|
spin-reverse
horizontal
|
tada
passing
|
vertical
passing-reverse
|
wrench
--- # Animate your own images! Behaves like `faa`! ```r anicon::cia("logo.png", rotate=90, size=3, border=T) ```
<img src="logo.png" style="height:3em; width:auto; "/>
```r anicon::cia("logo.png", animate="wrench", ltext="Hello!", grow=20, flip="horizontal", border=T, bgcolor="#9BB1FF") ```
Hello!<img src="logo.png" style="height:2.25em; width:auto; transform: scaleX(-1); -webkit-transform: scaleX(-1); " align="middle"/>
```r anicon::cia("logo.png", animate="wrench", anitype="parent-hover", ltext="Hello!", size=3) ```
Hello!<span class=" faa-wrench " style=" display: -moz-inline-stack; display: inline-block; transform: rotate(0deg);"> <img src="logo.png" style="height:3em; width:auto; "/> </span>
--- # Works with gif as well! ```r anicon::cia("party_parrot.gif", size=3, border=T) ```
<img src="party_parrot.gif" style="height:3em; width:auto; "/>
### You can disable animation in `cia` by `animate=F` ```r anicon::cia("party_parrot.gif", animate=F, rotate=90, size=3) ```
<img src="party_parrot.gif" style="height:3em; width:auto; "/>
Find more fun gifs at [slackmojis](https://slackmojis.com/)! --- class: middle, center # Icon layering and more to come! <i class="fas fa-leaf fa-10x"></i>
<i class="fas fa-heart fa-10x faa-pulse animated " data-fa-transform="shrink-10 left-16 " style=" color:Tomato;"></i>
<br><br>
<i class="fab fa-twitter fa-2x faa-wrench " style=" color:#1DA1F2;"></i>@statsgen
<i class="fab fa-github fa-2x faa-flash "></i>https://github.com/emitanaka/anicon