how to build an array of colors

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am working on an image using the gd library in php. I want to make
an array of colors, based on RGB arguments for the ImageColorAllocate
() function.

For the set [ 0, 64, 128, 192, 255 ] , I want to create every
combination ( the Cartesian product? ) of colors. How would I do this?
I was thinking a set of nested loops, but I think I would get
duplications using that method.

Another thought I had was to use MySQL to build the Cartesian product
of the set. That would be easier than me trying to make and
troubleshoot some php code to make a Cartesian product.


Re: how to build an array of colors

lawpoop wrote:
Quoted text here. Click to load it

Nested loops or recursion - neither will give you duplicates, if you do
it properly.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline