Description Usage Arguments Examples
Output and render functions for using thorn
within Shiny
applications and interactive Rmd documents.
1 2 3 | thornOutput(outputId, width = "100%", height = "100%")
renderThorn(expr, env = parent.frame(), quoted = FALSE)
|
outputId |
output variable to read from |
width, height |
a valid CSS measurement (like |
expr |
an expression that generates a shader created with
|
env |
the environment in which to evaluate |
quoted |
logical, whether |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # use a shader as the background of a Shiny app ####
library(thorn)
library(shiny)
ui <- fluidPage(
thornOutput("thorn", width = "100%", height = "100%"),
br(),
sidebarLayout(
sidebarPanel(
sliderInput(
"slider", "Slide me",
value = 10, min = 0, max = 20
),
selectInput(
"select", "Select me", choices = c("Choice 1", "Choice 2")
)
),
mainPanel()
)
)
server <- function(input, output){
output[["thorn"]] <- renderThorn({
thorn("biomorph2")
})
}
if(interactive()){
shinyApp(ui, server)
}
# all available shaders ####
library(thorn)
library(shiny)
ui <- fluidPage(
br(),
sidebarLayout(
sidebarPanel(
wellPanel(
radioButtons(
"shader", "Shader",
choices = c(
"thorn",
"thorn-color",
"ikeda",
"biomorph1",
"biomorph2",
"biomorph3",
"sweet",
"apollony",
"smoke"
)
)
)
),
mainPanel(
thornOutput("shader", width = "calc(100% - 15px)", height = "400px")
)
)
)
server <- function(input, output){
output[["shader"]] <- renderThorn({
thorn(input[["shader"]])
})
}
if(interactive()){
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.