Comments (9)
History-wise, I think these were added by people who are mostly doing HTML stuff and thus writing out JSON strings.
But we did eventually develop a more Julian approach:
julia> using Colors
julia> colorant"indianred"
RGB{N0f8}(0.804,0.361,0.361)
This actually does the work at compile-time, so performance-wise is equivalent to inserting the constant RGB{N0f8}(0.804,0.361,0.361)
. However, it requires an explicit color name; if you want to parse this for a variable, then use parse(Colorant, cname)
where cname
is a string.
I see the docs make this a bit confusing. Would you by any chance be willing to submit a pull request that clarifies this?
from colors.jl.
PR submitted.
but maybe this part of doc could be a good place to show how to convert to RGB{N0f32}
(for example)
but it could also be in https://github.com/JuliaGraphics/ColorTypes.jl
from colors.jl.
RGB{N0f32}(colorant"indianred")
from colors.jl.
@scls19fr, why would convert to RGB{N0f32}
? Do you realize that is 96-bit color? Did you actually mean to convert to RGB24
by any chance?
from colors.jl.
oh yes... that's a bit overkilled
from colors.jl.
Given values in tuples, I'm wondering if
shouldn't be changed from Int64
to UInt8
from colors.jl.
I'm less worried about the data type and more about the value; should we use 1.0 instead of 255?
The current conversions (including reinterpreting as N0f8
) are done algorithmically here:
Lines 108 to 110 in 33ce6c0
from colors.jl.
Working with float can lead to numerical issues...
this kind of values should be stored in a structure which can store for example fractional values (1/3 for example)
My 2 cts
from colors.jl.
Just FYI that table is only for internal use anyway, I don't think there's anything about it that leaks out to the user. By reinterpreting as N0f8
we're effectively storing all of them at ratios with denominator 255.
julia> colorant"indianred"
RGB{N0f8}(0.804,0.361,0.361)
julia> dump(colorant"indianred")
RGB{FixedPointNumbers.Normed{UInt8,8}}
r: FixedPointNumbers.Normed{UInt8,8}
i: UInt8 0xcd
g: FixedPointNumbers.Normed{UInt8,8}
i: UInt8 0x5c
b: FixedPointNumbers.Normed{UInt8,8}
i: UInt8 0x5c
from colors.jl.
Related Issues (20)
- Not work on Ubuntu 2004 HOT 5
- RGB -> XTerm256 approximation? HOT 13
- move storage type conversion trait from ImageCore to Colors HOT 6
- Optimizing the types used for intermediate calculations HOT 5
- Source of the YIQ transform matrix HOT 1
- is `inv` on Colors well defined? HOT 4
- Fatal performance degradation due to precompilation or inference bugs HOT 8
- MethodError: no method matching coloralpha(::Type{RGB24}) HOT 1
- What should `default_brettel_neutral` be? HOT 1
- Ambiguity with AbstractTrees
- 'Render' colours in REPL HOT 15
- in the README, put a link on the home page HOT 2
- colorwheel generator HOT 1
- add colorwheel generator HOT 1
- Release v0.13? HOT 2
- Ambiguous show method for `Union{}[]` HOT 3
- colormap("<Color>", maxcount; w=<Int>, logscale=<Bool>) stackoverflows HOT 7
- oklab/oklch for CSS4 and cheap deltaE HOT 1
- BGR interpreted as RGB HOT 1
- Luv and LCHuv gives incorrect color values for low lightness cyan HOT 1
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 colors.jl.