Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created August 8, 2023 18:39
Show Gist options
  • Save vjcitn/c21cc15eff8f204b0862652e044cb540 to your computer and use it in GitHub Desktop.
Save vjcitn/c21cc15eff8f204b0862652e044cb540 to your computer and use it in GitHub Desktop.
simple color model exploration with shiny
library(shiny)
colorapp2 = function ()
{
colordot = function (r, g, b) {
plot(0, 0, col = grDevices::rgb(r, g, b), pch = 19, cex = 15)
}
ui = fluidPage(
sidebarLayout(
sidebarPanel(
helpText("sliders for color balance"),
sliderInput("red", "red", min = 0, max = 1, step = 0.05, value = 1),
sliderInput("green", "green", min = 0, max = 1, step = 0.05, value = 0),
sliderInput("blue", "blue", min = 0, max = 1, step = 0.05, value = 0)
),
mainPanel(
tabsetPanel(
tabPanel("dot", plotOutput("dot"))
) # end tabsetPanel
) # end mainPanel
) # end layout
) # end fluidpage
server = function(input, output) {
output$dot = renderPlot({
colordot(input$red, input$green, input$blue)
})
}
runApp(list(ui = ui, server = server))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment