Closed Sumidu closed 3 years ago
The colour names that are supported are all the colours from grDevices::colours(distinct = TRUE)
You can see the list here https://github.com/daattali/jquery-colourpicker/blob/a87752bcd31e9911006dfd8acb923970016d6e87/js/colourpicker.js#L627
No, I meant the other way around. To return the text string of the X11 palette. In my use case I create several colourpickers programmatically. And the following plot-function uses these values directly and requires X11 colour names.
Alternatively, is there an easy way for me to wrap your input function, and pipe the result through this:
colhex2col <- function(colhex) {
# Convert hex to RGB
mycol <- col2rgb(colhex)
# Convert all x11 colors to RGB, adn transform
all_colors <- data.frame(col2rgb(grDevices::colors()))
all_colors <- setNames(all_colors, grDevices::colors())
by_rgb <- data.frame(t(all_colors))
by_rgb <- sort(apply(by_rgb,1, function(x) sum(abs(x - mycol)) ))
names(by_rgb[1])
}
Are you wanting to pass an X11 colour name into the colourInput, or do you want to retrieve the X11 colour name that is currently selected in the input?
Pass in X11 Colour. Pick RGB style, but retrieve the (closest) X11 Colour.
But I just realized I needed to add the returnName=TRUE
to get a similar thing.
Sorry about the hassle. Thank you for this awesome package 👍
Hi, thank you for your amazing tool. It would be awesome for my use case if instead of the R palette, I could pick the X11 palette.
In R you can get it from
grDevices::colours()
Thank you :) André