mbjordan / colors Goto Github PK
View Code? Open in Web Editor NEWA simple color manipulation javascript library.
Home Page: http://honyovk.com/Colors/
License: MIT License
A simple color manipulation javascript library.
Home Page: http://honyovk.com/Colors/
License: MIT License
Hi Matthew,
I tried using colors.js (and the minimized version) to generate complementary colors for a given hex value, but the output is returning much too large a value (see notes below). Honestly, I'm not exactly sure why it works in your demo page. Otherwise a very nice tool. thanks!
value in >> value out for Colors.complement('#FFFFFF') (or using '#ffffff')
to fix the issue, I modified the associated code in the (raw colors.js) complement method as follows:
rtn += (this.rgb2hex(255 - this.hex2rgb(c.substr(0, 2)))).substr(1, 2);
rtn += (this.rgb2hex(255 - this.hex2rgb(c.substr(2, 2)))).substr(1, 2);
rtn += (this.rgb2hex(255 - this.hex2rgb(c.substr(4, 2)))).substr(1, 2);
There's probably a more elegant solution, but this works for me, anyway.
Most likely (I haven't tested) the issue affects the abbreviated form #XYZ as well.
To make the code base more maintainable, I'm going to break each method out into their own modules and apply a more functional style of programming to each one.
More info to come soon.
Am I reading the source right or does this module basically only do color conversions and caluculation of complementary color? Seems like a rather incomplete set of utilities. I'm compiling a more complete library here if you're interested in helping: https://github.com/fresheneesz/xolor
currently only works on client
The rgb2hex() function sometimes gives too short hex values, consisting of only 5 characters after the '#'.
Some RGB values that return invalid hex values are:
R: 54, G: 15, B: 69 (gives #36f45)
R: 10, G: 250, B: 58 (gives #afa3a)
R: 28, G: 10, B: 53 (gives #1ca35)
This is a nice little utility. Would you consider tagging the versions and putting it on bower so it's easier to get? Just tag with semver (e.g. git tag v1.2.3
) and add a bower.json
file structured:
{
"name": "my-project",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"<name>": "<version>",
"<name>": "<folder>",
"<name>": "<package>"
},
"devDependencies": {
"<test-framework-name>": "<version>"
}
}
Then submit: bower register <my-package-name> <git-endpoint>
If you want I can submit a PR.
Update to version 2.0 with major changes to the API and testing.
The hsv2hsl
method is not returning valid HSL color values.
I believe something went wrong at some point with some variable names.
I tried calling this:
Colors.complement('#ffffff')
which returned:
"##000000#000000#000000"
also this:
Colors.complement('#adf004')
returned:
"##525252#fff#fbfbfb" so I cant just split it by '#' because I wouldn't know which value to use.
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.