Comments (2)
Hi Petr, it's taken me a while to get round to this. This should now work:
remotes::install_github("matt-dray/coloratio")
coloratio::cr_choose_bw(c("white", "black"))
## [1] "black" "white"
Does that help?
I haven't closed this issue because I haven't yet vectorisedcr_choose_color()
. This function is a bit different to cr_choose_bw()
because the user can set the length of the return object with n
(i.e. they want the n colors with greatest contrast). So, vectorising cr_choose_color()
might mean returning a list of the same length as col
, with elements that are all of length n
. Or maybe n
is coerced to 1
when a vector of length 2 more more is supplied to col
, i.e. it will only return the single color with greatest contrast. Ideas welcome!
from coloratio.
Hi Matt,
I just stumbled upon a similar situation (labelling a heatmap) in my work and was reminded of this exchange - sorry for not reacting! Many thanks, it does help indeed.
Re cr_choose_color()
, returning a list would not make it usable in after_scale()
, so with that purpose in mind I would go for the latter option, but then perhaps there are other use cases.
Alternatively, you could have cr_choose_one_color()
or allow the user to control the type of output via an argument, but that makes things a bit opaque.
from coloratio.
Related Issues (14)
- Add function to decide whether white or black text is better for a given background colour
- Find out if this already exists HOT 1
- Standardise 'color'
- Suggest `farver::decode_colour()` instead of `cr_choose_bw()`?
- Is `cr_choose_col()` redundant? HOT 1
- Provide preview of text on background given user-supplied colours HOT 1
- Follow WCAG 3.0
- Provide RGB input to get_ratio() HOT 2
- Build {pkgdown} site
- Add tests
- Sample colours from input image and compare pairwise ratios
- Provide pairwise contrast comparisons for >2 input colours
- Consider function naming system
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coloratio.