-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend color
for tuple of RGB components
#145
Conversation
col = color in keys(color_decode) ? color_decode[color] : Int(color) | ||
str = string(args...) | ||
printstyled(io, str; color = col) | ||
function crayon_256_color(color::UserColorType)::ColorType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnnychen94, this seems a bit hacky, should I PR to Crayons.jl
instead to have stable API conversions to 256 color ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposing a stable API in Crayons sounds okay to me but I know very little about this. I don't know if it's useful, there are some discussions on JuliaGraphics/Colors.jl#473
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the link. What we need in UnicodePlots
is something generic working on all terminals. Since we use printstyled(...)
I think the implementation in this PR is ok using 0-255
integers.
@KristofferC, do you have any advice for this ?
The CI failures are related to Except for Heatmap, for which this PR fixes a regression, dotcanvas & heatmapcanvas are now similar in terms of colors for the same data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the back and forth. I just noticed that this PR doesn't have associated test cases added. Can you also add some tests for the new keyword types?
Currently, when I try barplot(["B", "A"], [2, 1]; color=(255, 0, 0))
it's broken. Looks like something is missing here?
Co-authored-by: Johnny Chen <[email protected]>
Good point, will do.
I don't understand, could you precise which keyword types you're talking about ?
Good catch ! Will fix. |
Sorry for the inaccuracy, I meant to test |
Oh ok, yes 👍 |
9145af8
to
c1d05eb
Compare
1cb087e
to
5b83026
Compare
a6e07f9
to
f126e20
Compare
I've inserted some colors tests covering We now have 3 colors type: After visual inspection against master using: root="$HOME/Downloads/UnicodePlots.jl" # fork
for f in $(find $root/test/references -name '*.txt'); do
echo; echo
echo "== local($f) =="
cat $f
echo
url="https://raw.githubusercontent.com/Evizero/UnicodePlots.jl/master/${f#$root/}"
echo "== remote($url) =="
wget -q -O - $url
done , I think this PR can be reviewed again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't look very carefully but the test looks good to me. Since a lot of references are changed so I assume there will be some implicit behavior differences, I'd like to bump a minor version to indicate some "breaking" changes, does it sound good to you? @t-bltg
Yes, I'm good with the minor bump. I will apply the changes in |
color
for tuple of RGB components
It's actually a major version bump 😄 v2.0.0 |
Allow passing arbitrary colors, e.g.:
Needed for
Plots.jl
, since we useRGB
values internally.Uses
Crayon
for color conversion: I think this is appropriate, sinceCrayon
is already aUnicodePlots
dependency used in Heatmaps, and itsANSIColor
type is coherent with terminal color output.With #136 applied, all tests pass with newly generated images:
Fix #20.
Fix #58.