Search Webmaster Help and Solution

[RESOLVED] Create Colors based on # of Items

Preferably using PHP, Id like to create X number of colors based on X number of items and using a predefined color range. For example:


ITEM -- VALUE
1 -- 1,234,567,890
2 -- 234,567,890
3 -- 34,567,890
4 -- 4,567,890
5 -- 567,890


Color Range
red = largest value
green = medium value
blue = smallest value


Example
Item 1 gets color red
Item 2 gets whatever color naturally comes between red and green
Item 3 gets color green
Item 4 gets whatever color naturally comes between green and blue
Item 5 gets color blue


Requirements
The code should be able to handle any number of items. 5 items was just an easy example.


Some Thoughts
- Number of items = number of colors
- How to divide a color range into number of items?
- Colors can be represented in decimal format: red=255,000,000 blue=000,000,255
- Can a formula be created, based on the color decimal format, to solve this problem?


I think its the math portion of the problem that Im stuck on right now.
Thanks for your help,

Nick Preferably using PHP, Id like to create X number of colors based on X number of items and using a predefined color range. For example:


ITEM -- VALUE
1 -- 1,234,567,890
2 -- 234,567,890
3 -- 34,567,890
4 -- 4,567,890
5 -- 567,890


Color Range
red = largest value
green = medium value
blue = smallest value


Example
Item 1 gets color red
Item 2 gets whatever color naturally comes between red and green
Item 3 gets color green
Item 4 gets whatever color naturally comes between green and blue
Item 5 gets color blue


Requirements
The code should be able to handle any number of items. 5 items was just an easy example.


Some Thoughts
- Number of items = number of colors
- How to divide a color range into number of items?
- Colors can be represented in decimal format: red=255,000,000 blue=000,000,255
- Can a formula be created, based on the color decimal format, to solve this problem?


I think its the math portion of the problem that Im stuck on right now.
Thanks for your help,

Nick

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).