emilhvitfeldt / prismatic Goto Github PK
View Code? Open in Web Editor NEWcolor manipulation R package Simply and Tidy
Home Page: https://emilhvitfeldt.github.io/prismatic/
License: Other
color manipulation R package Simply and Tidy
Home Page: https://emilhvitfeldt.github.io/prismatic/
License: Other
just a reminder... lots of performance to gain :-)
It would be great if plot.colors()
could also add text with the color name/hex to the swatch
Prepare for release:
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
Submit to CRAN:
usethis::use_version('minor')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
Prepare for release:
devtools::build_readme()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
urlchecker::url_check()
cran-comments.md
Submit to CRAN:
usethis::use_version('major')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
Prepare for release:
usethis::use_cran_comments()
devtools::check()
devtools::check_win_devel()
rhub::check_for_cran()
cran-comments.md
Submit to CRAN:
usethis::use_version('minor')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
usethis::use_news_md()
Something like clr_alpha(col, alpha)
that would translate alpha values to their hex version (e.g. https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4) and paste them to the end of the hex color code
Prepare for release:
git pull
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
git push
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
git push
usethis::use_github_release()
usethis::use_dev_version()
git push
I noticed that rotate()
uses hsl rather than hcl, but my recollection is that hcl is more perceptually uniform, so I think it would be better to use hcl.
I was also surprised see that "HSL" is the default in clr_lighten()
โ I re-read the colorspace paper to check that I wasn't missing something, but I see:
HLS() (Hue-Lightness-Saturation) is another transformation of (s)RGB that tries to capture the perceptual axes. It does a somewhat better job but the dimensions are still strongly confounded. See Wikipedia (2019f) for more details.
Thank you for such a nice package, @EmilHvitfeldt! ๐
I wonder if there is plan for adding a pretty_print() method for dataframes of colors?
It's not a perfect match for this package, but it seems like a reasonable home:
rel_l <- function(x) {
scale <- function(x) {
ifelse(x <= 0.03928, x / 12.92, ((x + 0.055) / 1.055)^2.4)
}
rgb <- farver::decode_colour(x) / 255
0.2126 * scale(rgb[, 1]) + 0.7152 * scale(rgb[, 2]) + 0.0722 * scale(rgb[, 3])
}
contrast_ratio <- function(x, y) {
x_l <- rel_l(x)
y_l <- rel_l(y)
(pmax(x_l, y_l) + 0.05) / (pmin(x_l, y_l) + 0.05)
}
This implements the WCAG 2.0 colour contrast computation (https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) which is useful for checking that colours have sufficient contrast to be easily readable.
https://twitter.com/ClausWilke/status/1175294017086640128
tannerhelland.com/3643/grayscale-image-algorithm-vb6/
Thanks for making this! Looks great.
Would it be possible to have colour
as an alias for color
in this package?
Pre-history
usethis::use_readme_rmd()
usethis::use_roxygen_md()
usethis::use_github_links()
usethis::use_pkgdown_github_pages()
usethis::use_tidy_labels()
usethis::use_tidy_style()
usethis::use_tidy_description()
urlchecker::url_check()
2020
usethis::use_package_doc()
@importFrom
directives here.usethis::use_import_from()
is handy for this.usethis::use_testthat(3)
and upgrade to 3e, testthat 3e vignetteR/
files and test/
files for workflow happiness.usethis::rename_files()
can be helpful.2021
usethis::use_tidy_dependencies()
usethis::use_tidy_github_actions()
and update artisanal actions to use setup-r-dependencies
cran-comments.md
Something like this maybe:
modify_hcl <- function(x, h, c, l) {
hcl <- as.data.frame(farver::decode_colour(x, to = "hcl"))
if (!missing(h)) {
h <- eval(substitute(h), envir = hcl)
} else {
h <- hcl$h
}
if (!missing(c)) {
c <- eval(substitute(c), envir = hcl)
} else {
c <- hcl$c
}
if (!missing(l)) {
l <- eval(substitute(l), envir = hcl)
} else {
l <- hcl$l
}
farver::encode_colour(cbind(h, c, l), from = "hcl")
}
Idea is to make it easy to do (e.g.) modify_hcl(x, h = 25)
or modify_hcl(x, h = h + 10)
One thing that could be super neat would be to use crayon for colouring the background during printing. You could simply use it if it was available so you'd only need to have it in suggests
Prepare for release:
devtools::check()
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
Submit to CRAN:
usethis::use_version('minor')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
hi friend! ๐ thanks for this package, it's very very useful!
right now it doesn't look like clr_lighten()
and clr_darken()
(maybe all of them? I'm only looking at the lighten/darken functions though) work well within a mutate, seemingly due to mismatch in length of the colour/shift arguments. curious if this is something you'd be open to supporting, or if I'm missing some way to do it! ty!
library(prismatic)
library(dplyr)
x <- c("#fbbcb8", "#bfdff6")
clr_darken(x)
#> <colors>
#> #CE170CFF #1B7BC0FF
# sad in mutate() though
colours <- tibble(color = x) %>%
mutate(darker = clr_darken(color))
#> Error: Problem with `mutate()` input `darker`.
#> x The length of `col` must be positive.
#> โน Input `darker` is `clr_darken(color)`.
# rowwise() doesn't help much?
colours <- tibble(color = x) %>%
rowwise() %>%
mutate(darker = clr_darken(color))
#> Error: Problem with `mutate()` input `darker`.
#> x The length of `col` must be positive.
#> โน Input `darker` is `clr_darken(color)`.
#> โน The error occured in row 2.
Prepare for release:
git pull
urlchecker::url_check()
devtools::build_readme()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
git push
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version(push = TRUE)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.