Comments (3)
I was able to solve the first one by just doing this, which could perhaps be added as an example on how to seed the color if you don't include something for initialization:
var rcolor = new RColor;
rcolor.hue = .5;
On the second one, what I did was just save my value for each id, so there was no need to request it more than once. However, I was using it for a gradient, so it was important for me to call the same color again, but with a different saturation. So I did add this:
RColor.prototype.getAgain = function(hex,saturation,value) {
if(typeof saturation !== "number") saturation = 0.5;
if(typeof value !== "number") value = 0.95;
var rgb = this.hsvToRgb(this.hue,saturation,value);
if(hex)
return "#" + this.padHex(rgb[0].toString(16))
+ this.padHex(rgb[1].toString(16))
+ this.padHex(rgb[2].toString(16));
else
return rgb;
};
That allowed me to do this for creating my gradient:
var color1 = rcolor.get(true);
var color2 = rcolor.getAgain(true, 0.4, 0.99);
from randomcolor.
Thanks Jeff for the feedback, this makes sense to me and I'll look into working it in.
from randomcolor.
I know it's been a while but wanted to update this since I've recently reworked this library.
I thought about this some more and I think it should be the job of whatever code is leveraging rcolor
to take care of saving or associating colors with IDs. The new API should make it easier for folks to override the hue, saturation and value options.
Going to focus on making sure this does one thing and one thing well (generating random colors). Appreciate you sharing your use case though!
from randomcolor.
Related Issues (4)
- Hex color literals need zero-padding. HOT 1
- RColor is not defined HOT 2
- Color proximity HOT 3
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 randomcolor.