Comments (6)
added in 8d98876
from colorschemes.jl.
Good idea!
I ended up adding the color map colors directly. But I did first try to convert the GLSL code, but I didn't really understand it enough to get the correct results:
function turbocolormap(x)
kRedVec4 = [-0.05195877, 5.18000081, -30.94853351, 81.96403246]
kGreenVec4 = [0.16207513, 0.17712472, 15.24091500, -36.50657960]
kBlueVec4 = [0.55305649, 3.00913185, -5.46192616, -11.11819092]
kRedVec2 = [-86.53476570, 30.23299484]
kGreenVec2 = [25.95549545, -5.02738237]
kBlueVec2 = [27.81927491, -14.87899417]
x = clamp(x, 0.0, 1.0)
v4 = [1.0, x, x^2, x^3]
v4zw = [v4[3], v4[4]]
v2 = v4zw * v4[3]
return [
dot(v4, kRedVec4) + dot(v2, kRedVec2),
dot(v4, kGreenVec4) + dot(v2, kGreenVec2),
dot(v4, kBlueVec4) + dot(v2, kBlueVec2)
]
end
from colorschemes.jl.
Great! I tried translating the GLSL version (https://gist.github.com/mikhailov-work/0d177465a8151eb6ede1768d51d476c7) and I got the same thing. I think it might just somehow have buggy coefficients but perhaps I've forgotten something critical about GLSL.
I made a notebook which computes a better approximation for us:
https://gist.github.com/c42f/f822a7b00258e5c73e27ac4a9db0f418
but I think the sampled version is quite a bit nicer.
from colorschemes.jl.
Looks like it's already made its way into d3 as well: https://observablehq.com/@mbostock/turbo
from colorschemes.jl.
Nice notebook! You got the same result at first as me, it looks a bit burnt or something at the top end... :)
ColorSchemes is a bit basic, it stores everything as arrays of colors. ColorSchemeTools.jl has a few functions for building schemes with functions, but it's all very simplistic and non-scientific...
Peter Kovesi's Perceptual Color Maps is the thing, I think.
from colorschemes.jl.
I like that you've got the original sampled colormap in here; I think it's nicer than the polynomial approximation anyway.
I guess this is resolved 👍
from colorschemes.jl.
Related Issues (20)
- OutOfMemoryError() HOT 1
- Release 3.20.0 HOT 1
- Release 3.21.0 HOT 1
- Release v3.22.0 HOT 1
- Kindlmann colormap HOT 4
- Release 3.23.0 HOT 1
- Scientific colour maps v8.0 HOT 6
- PNW colors HOT 6
- Release 3.24.0 HOT 1
- That `*` can be used to concatenate should be documented
- How to control the center color of diverging colorschemes HOT 2
- How do I know if a color scheme is continuous or categorical? HOT 2
- A consistent case pattern
- Unnecesary licence files
- Releases HOT 3
- Documentation `get_inverse` example is broken HOT 1
- optimized get(colorscheme, data) function HOT 1
- Release 3.18.0 HOT 3
- Release 3.19.0 HOT 1
- `firstindex` method error in color scheme HOT 2
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 colorschemes.jl.