我有4个png图像,我想用它来创建一个小动画。我希望能够设置图像之间的速度,并具有播放/暂停,后退,前进按钮。这可能吗?
我找到了animation
包,但我不认为可以使用png代替R图来创建动画。
目标是在R闪亮的演示文稿中使用此动画。因此,闪亮可能是一种选择。
谢谢!
我现在的解决方案是有很多幻灯片:
## figures/Timeline {.flexbox .vcenter}
![figures/Timeline 1](figures/Timeline/1.png)
## figures/Timeline {.flexbox .vcenter}
![figures/Timeline 2](figures/Timeline/2.png)
答案 0 :(得分:0)
这是一个使用闪亮的解决方案:
## Test
```{r, echo=FALSE, message=F}
server <- shinyServer(function(input, output, session) {
# Send a pre-rendered image, and don't delete the image after sending it
output$preImage <- renderImage({
filename <- normalizePath(file.path('./figures/vertchart',
paste(input$n, '.png', sep = '')))
# Return a list containing the filename and alt text
list(src = filename,
alt = paste("Image number", input$n))
}, deleteFile = FALSE)
})
ui <- shinyUI(
fluidPage(
absolutePanel(
top = 0, right = 20, width = 200,
draggable = TRUE,
wellPanel(
sliderInput(
"n", "", min = 1, max = 5, value = 1, animate = animationOptions(interval =
1200)
)
),
style = "opacity: 0.99"
),
imageOutput("preImage", width = "100%"
)
))
shinyApp(ui = ui, server = server)
```