Solved

avoiding darker colors

Posted on 2014-09-05
3
105 Views
Last Modified: 2014-09-06
hi experts
In my javascript code i am using

colors[item] = '#' + Math.random().toString(16).slice(2, 8);

Open in new window

to generate a random color.

But sometimes the color generated is black which i dont want.
Is there anyway i can avoid black or darker colors?

thanks.
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 40306969
You can try generating the values in the HSV color space, then converting them into the RGB color space.
Another option would be to normalize the randomly generated RGB values.

Either way, you'd have to generate each color value separately, rather than all at once.
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40307057
If you are not concerned with including EVERY light color among the 16 million possibilities you could just limit the script so that it returns just the higher hex digits. You would still have millions of possible combinations.

jsfiddle:

http://jsfiddle.net/w7p9aora/
0
 

Author Comment

by:royjayd
ID: 40307754
thanks,
Any help with this question will be greatly appreciated.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28511714.html#a40304512
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question