evercoder / culori Goto Github PK
View Code? Open in Web Editor NEWA comprehensive color library for JavaScript.
Home Page: https://culorijs.org
License: MIT License
A comprehensive color library for JavaScript.
Home Page: https://culorijs.org
License: MIT License
Arguments for enumerable
{ ...color }
maintains the flags.Arguments against enumerable
{ ...color }
will result in inaccurate flags.blue, green, 8 colors: https://beta.observablehq.com/@danburzo/culori-scales-test
Like css
but outputs to the formats defined in Color Module Level 4.
interpolate(color_array, mode = 'rgb')
returns an interpolator function that takes an argument [0, 1].
because the index will be passed as the second parameter
For linear interpolation:
For spline interpolation:
Simple, Euclidean distance + read up on these: http://bl.ocks.org/mourner/8a3968f74da743a754af
L = 0.2126 * R + 0.7152 * G + 0.0722 * B
in LRGB space.
contrast = (L1 + 0.05) / (L2 + 0.05)
in the WGAG spec.
...in both linear and spline interpolators. Also need to check for correct hue normalization before and after the process.
e.g. red to blue https://beta.observablehq.com/@danburzo/culori-scales-test
Regardless of the various formats the colors come in, they ultimately reflect a RGB(A) value, so it makes sense to keep the internal format as R, G, B, A (floating-point values): in -> RGBA -> out
However, for the purposes of color scales, one might have three colors defined:
H - 120, S, L, A
H, S, L, A
H + 120, S, L, A
In which case H could go beyond [0, 360]
and we need to store the original value to properly interpolate.
e.g. https://github.com/acterhd/hcg-color
Currently, parsers cannot be added - let's have string parsing match CSS Color Level 4.
Converters can be created, but they can't be registered, so we need an API for that.
Reading material:
swatches(interpolator, no_of_colors)
to generate color scales.
scale(colors, mode, no_of_colors)
can be implemented as swatches(interpolate(colors, mode), no_of_colors)
.
don't allow mix of percentages and numbers.
With closed and open variants, like in D3. the closed version can be useful for radial sliders for hue.
Use a v-p tree to index() a set of colors based on a specific difference() to enable queries of the type: what are the closest colors in the index to a given color?
Reference: http://pnylab.com/papers/vptree/main.html
Example JS implementation: https://github.com/fpirsch/vptree.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.