-
Notifications
You must be signed in to change notification settings - Fork 48
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
Make display of color swatches slightly robust #463
Conversation
This reduces the risk of having invalid suffixes when converting numbers to strings. This also supports indices that start with other than 1. There is almost no improvement in performance.
Codecov Report
@@ Coverage Diff @@
## master #463 +/- ##
==========================================
- Coverage 92.53% 92.42% -0.12%
==========================================
Files 10 10
Lines 951 950 -1
==========================================
- Hits 880 878 -2
- Misses 71 72 +1
Continue to review full report at Codecov.
|
for (i, c) in enumerate(cs) | ||
i > actual_max_swatches && break | ||
hexc = hex(color(c)) | ||
opacity = string(round(float(alpha(c)), digits=4)) |
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.
alpha()
may return a FixedPoint
number. FixedPointNumbers v0.8 does not support round(x, digits=n)
, and the fallback returns a floating-point number. However, this problem has been fixed in JuliaMath/FixedPointNumbers.jl#235.
julia> round(0.5N0f8, digits=4)
0.502f0 # FPN v0.8
0.502N0f8 # FPN #master
Here is another problem. Unlike Float32
etc., string(::FixedPoint)
currently returns a string with the suffix.
julia> string(0.5N0f8)
"0.502N0f8"
julia> string(0.5f0)
"0.5"
Perhaps string(::FixedPoint)
should return a string without suffix, but that is a matter of FixedPointNumbers. (Edit: cf. JuliaMath/FixedPointNumbers.jl#241)
Would it be possible to make a release with this PR? Some weird errors in Pluto and some |
Colors v0.12.7 was released. If the issue is still not resolved, please report it. |
Thanks! |
This reduces the risk of having invalid suffixes when converting numbers to strings. This also supports indices that start with other than 1.
There is almost no improvement in performance.