Fooidge / PleaseJS

JavaScript Library for creating random pleasing colors and color schemes
2.28k stars 159 forks source link

Help with outputing color values to colored divs, similar to example page #30

Closed fluxxus closed 10 years ago

fluxxus commented 10 years ago

Hi, I want to create something similar to the example page of Please.js. Basically to have a few divs, and have their background color changed based upon function called.

It is easy for just one color, but how to output the value of a function that creates a color scheme?

Here is the fiddle with one color, and the setup is ready with four divs to accept the values for a color scheme, but I don't know how to do it.

http://jsfiddle.net/pefqj1uu/1/

jmanuel1 commented 10 years ago

A scheme is an array of colors, and so Please.make_color return an array. Assuming you already have a scheme named scheme:

alert(scheme[1]); /* Get one of the scheme colors, print it in a window. */

Then if you want to color a div:

document.getElementById("someDiv").style.backgroundColor = scheme[1];

And that div should be whatever color PleaseJS came up with.

fluxxus commented 10 years ago

@jmanuel1 Thanks for your help. Could you please take a look at this fiddle: http://jsfiddle.net/pefqj1uu/2/

I have the div with one color change its value, but the four divs that would need to change based on Please.js color scheme, that is not working.

Thanks

fluxxus commented 10 years ago

Ok, I managed it on my own. Here is the fiddle: http://jsfiddle.net/pefqj1uu/7/

There is a little error in the documentation !!! Please.make_scheme( { h: 130, s: .7. v: .75 }, { scheme_type: "complement", format: "hex" });

There should be a coma after saturation, not a period.