Skip to content

Commit

Permalink
Hspread not in table but not in score
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Sep 17, 2024
1 parent fb4c941 commit b7c5317
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 114 deletions.
139 changes: 43 additions & 96 deletions R/c4a_gui.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ c4a_gui = function(type = "cat", n = NA, series = "all") {
shiny::selectizeInput("sort", "Sort palettes", choices = structure(c("name", "rank"), names = c("Name", .C4A$labels["cbfriendly"])), selected = "name"),
shiny::div(style = "margin-top: 5px;", shiny::checkboxInput("sortRev", "Reverse sorting", value = FALSE)),
#shiny::div(style = "margin-bottom: 5px;", shiny::strong("Select")),
shiny::div(class = "control-label", "Select"),
shiny::div(class = "control-label2", "Filter"),
shiny::uiOutput("filtersUI"),

shiny::div(class = "control-label", "Palette series"),
shiny::div(class = "control-label2", "Palette series"),

shiny::div(class = 'multicol',
shiny::checkboxGroupInput("series", label = "", choices = allseries, selected = series, inline = FALSE)),
Expand All @@ -232,63 +232,10 @@ c4a_gui = function(type = "cat", n = NA, series = "all") {
shiny::column(width = 3,
shiny::radioButtons("cvd", "Color vision", choices = c(Normal = "none", 'Deutan (red-green blind)' = "deutan", 'Protan (also red-green blind)' = "protan", 'Tritan (blue-yellow)' = "tritan"), selected = "none"),
shiny::radioButtons("textformat", "Text", choices = c("None" = "none", "Hex" = "hex", "RGB" = "RGB", "HCL" = "HCL"), inline = T),
shiny::div(class = "control-label", "Underlying scores"),
shiny::checkboxInput("advanced", "Show scores", value = FALSE)
shiny::div(class = "control-label3", "Underlying scores"),
shiny::div(style = "margin-top: 5px;", shiny::checkboxInput("advanced", "Show scores", value = FALSE))
),

# shiny::fluidRow(
# shiny::column(width = 4,
# shiny::radioButtons("type1", "Palette type", choices = types1, selected = type1),
# shiny::conditionalPanel(
# condition = "input.type1 == 'biv'",
# shiny::selectizeInput("type2", "Subtype", choices = types2[["biv"]], selected = type2))),
# shiny::column(width = 4,
# shiny::conditionalPanel(
# condition = "input.type1 != 'biv'",
# shiny::sliderInput("n", "Number of colors", min = ns$nmin, max = ns$nmax, value = ns$n, ticks = FALSE)),
# shiny::uiOutput("checkOnly"),
# shiny::conditionalPanel(
# condition = "input.type1 == 'biv'",
# shiny::fluidRow(
# shiny::column(6,
# shiny::uiOutput("nbivUI")),
# shiny::column(6,
# shinyjs::disabled(shiny::sliderInput("mbiv", "Number of rows", min = 3, max = 7, value = 3, ticks = FALSE))))),
# shiny::checkboxInput("na", "Color for missing values", value = FALSE),
# shiny::conditionalPanel(
# condition = "input.type1 == 'seq' || input.type1 == 'div'",
# shiny::fluidRow(
# shiny::column(4,
# #shiny::br(),
# shiny::radioButtons("auto_range", label = "Range", choices = c("Automatic", "Manual"), selected = "Automatic")),
# shiny::conditionalPanel(
# condition = "input.auto_range == 'Manual'",
# shiny::column(8,
# shiny::div(style = "font-size:0;margin-bottom:-10px", shiny::sliderInput("range", "", min = 0, max = 1, value = c(0,1), step = .05)),
# shiny::uiOutput("range_info"))
# )
# ))),
# shiny::column(width = 4,
# shiny::radioButtons("cvd", "Color vision", choices = c(Normal = "none", 'Deutan (red-green blind)' = "deutan", 'Protan (also red-green blind)' = "protan", 'Tritan (blue-yellow)' = "tritan"), selected = "none")
# )),
# shiny::fluidRow(
# shiny::column(width = 4,
# shiny::div(style = "margin-bottom: 5px;", shiny::strong("Palette series")),
# shiny::div(class = 'multicol',
# shiny::checkboxGroupInput("series", label = "", choices = allseries, selected = series, inline = FALSE)),
# shiny::fluidRow(
# shiny::column(12, align="right",
# shiny::actionButton("all", label = "All"),
# shiny::actionButton("none", label = "None"),
# shiny::actionButton("overview", label = "Overview")))),
# shiny::column(width = 4,
# shiny::uiOutput("sortcolorUI")),
# shiny::column(width = 4,
# shiny::selectizeInput("sort", "Sort palettes", choices = structure(c("name", "rank"), names = c("Name", .C4A$labels["cbfriendly"])), selected = "name"),
# shiny::checkboxInput("sortRev", "Reverse sorting", value = FALSE),
# shiny::checkboxInput("advanced", "Show scores", value = FALSE),
# shiny::radioButtons("textformat", "Text", choices = c("None" = "none", "Hex" = "hex", "RGB" = "RGB", "HCL" = "HCL"), inline = T)
# )))
),

shiny::fluidRow(
Expand Down Expand Up @@ -380,43 +327,7 @@ c4a_gui = function(type = "cat", n = NA, series = "all") {
shiny::column(width = 6,
infoBoxUI("infoFair", "Fairness"),
plotOverlay("anaFair", width = "600px", height = "600px", "aniFair")))),
shiny::tabPanel("Naming",
value = "tab_name",
shiny::fluidRow(
shiny::column(width = 12,
shiny::selectizeInput("namePal", "Palette", choices = init_pal_list),
infoBoxUI("infoName", "Naming table (in development)"),
plotOverlay("anaName", width = "1000px", height = "600px", "aniName"))),
#shiny::plotOutput("namePlot", height = "600px", width = "1000px"))),
shiny::fluidRow(
shiny::column(width = 12,
shiny::sliderInput("nameAlpha", "Clarity level", min = .5, max = .C4A$naming_softmax$a + 2, step = .5, value = .C4A$naming_softmax$a))),
#shiny::actionButton("showWeights", "Show weight calibration"))),
# shiny::conditionalPanel(
# condition = "input.showWeights % 2 == 1",
# shiny::fluidRow(
# shiny::column(width = 3,
# shiny::sliderInput("w_1", "Green", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[1])),
# shiny::sliderInput("w_2", "Blue", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[2])),
# shiny::sliderInput("w_3", "Purple", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[3])),
# shiny::sliderInput("w_4", "Pink", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[4]))
# ),
# shiny::column(width = 3,
# shiny::sliderInput("w_5", "Yellow", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[5])),
# shiny::sliderInput("w_6", "Brown", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[6])),
# shiny::sliderInput("w_7", "Orange", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[7])),
# shiny::sliderInput("w_8", "Red", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[8]))
# ),
# shiny::column(width = 3,
# shiny::sliderInput("w_9", "White", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[9])),
# shiny::sliderInput("w_10", "Gray", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[10])),
# shiny::sliderInput("w_11", "Black", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[11])),
# shiny::actionButton("w_do", "Update naming data")
# )
# )
# )

),
shiny::tabPanel("Contrast",
value = "tab_cont",
shiny::fluidRow(
Expand Down Expand Up @@ -488,7 +399,43 @@ c4a_gui = function(type = "cat", n = NA, series = "all") {
shiny::plotOutput("float_letters_AB", "Float letter", height = 150, width = 300)
))),

shiny::tabPanel("Naming",
value = "tab_name",
shiny::fluidRow(
shiny::column(width = 12,
shiny::selectizeInput("namePal", "Palette", choices = init_pal_list),
infoBoxUI("infoName", "Naming table (in development)"),
plotOverlay("anaName", width = "1000px", height = "600px", "aniName"))),
#shiny::plotOutput("namePlot", height = "600px", width = "1000px"))),
shiny::fluidRow(
shiny::column(width = 12,
shiny::sliderInput("nameAlpha", "Clarity level", min = .5, max = .C4A$naming_softmax$a + 2, step = .5, value = .C4A$naming_softmax$a))),
#shiny::actionButton("showWeights", "Show weight calibration"))),
# shiny::conditionalPanel(
# condition = "input.showWeights % 2 == 1",
# shiny::fluidRow(
# shiny::column(width = 3,
# shiny::sliderInput("w_1", "Green", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[1])),
# shiny::sliderInput("w_2", "Blue", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[2])),
# shiny::sliderInput("w_3", "Purple", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[3])),
# shiny::sliderInput("w_4", "Pink", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[4]))
# ),
# shiny::column(width = 3,
# shiny::sliderInput("w_5", "Yellow", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[5])),
# shiny::sliderInput("w_6", "Brown", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[6])),
# shiny::sliderInput("w_7", "Orange", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[7])),
# shiny::sliderInput("w_8", "Red", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[8]))
# ),
# shiny::column(width = 3,
# shiny::sliderInput("w_9", "White", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[9])),
# shiny::sliderInput("w_10", "Gray", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[10])),
# shiny::sliderInput("w_11", "Black", min = 0, max = 1.2, step = 0.01, value = unname(.C4A$boynton_weights[11])),
# shiny::actionButton("w_do", "Update naming data")
# )
# )
# )

),


shiny::tabPanel("Application",
Expand Down Expand Up @@ -702,12 +649,12 @@ c4a_gui = function(type = "cat", n = NA, series = "all") {

output$filtersUI = shiny::renderUI({
type = get_type12()
filters = c("Colorblind-friendly" = "cbf",
filters = c("Only n = nmax (categorical only)" = "nmax",
"Colorblind-friendly" = "cbf",
"Fair" = "fair",
"Nameability" = "naming",
"Good contrast ratio with white" = "crW",
"Good contrast ratio with black" = "crB",
"Only n = nmax (categorical only)" = "nmax")
"Nameability" = "naming")

filters_type = if (type == "cat") {
filters
Expand Down
8 changes: 4 additions & 4 deletions R/c4a_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ table_columns = function(type, show.scores) {
} else {
# qn = c(qn, "nameable", "contrastWT", "contrastBK", "contrast", "float")
# qs = c(qs, "nameability", "CRwt", "CRbk", "CRmin", "Blues")
qn = c(qn, "hues", "chroma", "nameable", "contrastWT", "contrastBK", "equiluminance", "float")
qs = c(qs, "Hspread", "Cmax", "nameability", "CRwt", "CRbk", "CRmin", "Blues")
qn = c(qn, "hues", "chroma", "contrastWT", "contrastBK", "equiluminance", "float", "nameable")
qs = c(qs, "Hspread", "Cmax", "CRwt", "CRbk", "CRmin", "Blues", "nameability")
sn = character(0)
}


if (show.scores) {
qn = c(qn, names(.C4A$CB_ranges[[type]]), .C4A$hcl, .C4A$rgb)
qs = c(qs, names(.C4A$CB_ranges[[type]]), .C4A$hcl, .C4A$rgb)
qn = c(qn, names(.C4A$CB_ranges[[type]]), .C4A$hcl2, .C4A$rgb)
qs = c(qs, names(.C4A$CB_ranges[[type]]), .C4A$hcl2, .C4A$rgb)
}
ql = gsub(" ", "", .C4A$labels[qn])

Expand Down
2 changes: 1 addition & 1 deletion R/get_z_n.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
get_z_n = function(z, n = NA, m = NA, filters, range = NA, colorsort = "orig") {
get_z_n = function(z, n = NA, m = NA, filters = character(0), range = NA, colorsort = "orig") {
# if (!is.null(n)) {

if ("nmax" %in% filters) {
Expand Down
11 changes: 8 additions & 3 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ do_cellspec = function(lst) {


rgb = c("Blues")
hcl = c("Cmax", "H", "HL", "HR", "Lmid", "Hwidth", "Hspread", "HwidthL", "HwidthR", "Lrange", "Crange", "fairness", "CRmin", "CRwt", "CRbk")

# for score file
hcl = c("Cmax", "H", "HL", "HR", "Lmid", "Hwidth", "HwidthL", "HwidthR", "Lrange", "Crange", "fairness", "CRmin", "CRwt", "CRbk")

# for table (with derived variables)
hcl2 = c("Cmax", "H", "HL", "HR", "Lmid", "Hwidth", "Hspread", "HwidthL", "HwidthR", "Lrange", "Crange", "fairness", "CRmin", "CRwt", "CRbk")

sortRev = c("cbfriendly", "harmonyRank", "fairness", "Cmax", "min_dist", "nameability", "Lmid", "Hwidth", "Hspread", "HwidthL", "HwidthR", "nmax", "CRwt", "CRbk", "Blues")

Expand Down Expand Up @@ -308,7 +313,7 @@ do_cellspec = function(lst) {
contrastWT = list("Contrast\nwt", tooltip = "Contrast with white (wt), black (bk), and between the colors (equiluminance)."),
contrastBK = list("bk", tooltip = ""),
equiluminance = list("eq.", tooltip = "If colors are equiluminant (i.e. very low contrast) visual illusions may appear"),
nameable = list("Naming", tooltip = "Are the colors are easy to name? If so, they are also easy to remember"),
nameable = list("Naming", tooltip = "Are the colors are easy to name? If so, they are also easy to remember (in development)"),
float = list("3D Blues", tooltip = "Is there a pure blue color that may cause a 3D illusion?"),
hues = list("Hues", tooltip = "How many different hues are used?"),
references = list("References", tooltip = "Click to copy the colors and references"))
Expand Down Expand Up @@ -386,7 +391,7 @@ do_cellspec = function(lst) {
nameable = list('NA' = "",
'FALSE' = "",
'TRUE' = list("✧",
tooltip = "Colors are easy to name, and therefore, easy to remember",
tooltip = "Colors are easy to name, and therefore, easy to remember (in development)",
escape = FALSE, extra_css = "font-size: 130%; vertical-align: -0.1em; line-height: 0px;")),
equiluminance = list('NA' = "",
'FALSE' = "",
Expand Down
10 changes: 1 addition & 9 deletions build/build_c4a_pals.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,13 @@ c4a_plot(sel)

res5 = colors_cbf_set(sel, k = 5, dE_min = 20)


pals = res5$palettes
names(pals) = paste0("pal", 1:length(pals))

pals_sel = pals[seq(1, length(pals), length.out = 500)]

ids = which(.C4A$z$series == "c4b")
s = .C4A$s[ids,,5]

s2 = s[which(s[,"Hwidth"] >= 240),]
palnames = substr(rownames(s2), 5, nchar(rownames(s2)))

c4a_sysdata_remove(series = "c4b")
c4a_load(c4a_data(pals[palnames], series = "c4b"))

c4a_load(c4a_data(pals_sel, series = "c4b"))

c4a_load(c4a_data(pals, series = "c4b"))

Expand Down
2 changes: 1 addition & 1 deletion build/build_palettes.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local({
p1 = pals[c("R3", "R4", "ggplot2", "Okabe-Ito")]
names(p1) = c("R3", "R4", "ggplot2", "okabe")

c4a_load(c4a_data(p1, types = "cat", series = "miscs"))
c4a_load(c4a_data(p1, types = "cat", series = "misc"))
})

###################################
Expand Down

0 comments on commit b7c5317

Please sign in to comment.