We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Smooth Palette Generator
Page Index Toggle Pages: 1
Smooth Palette Generator? (Read 1003 times)
Smooth Palette Generator?
Jul 28th, 2005, 5:39pm
 
How would i go about making a palette generator..
i need an array of a definable size which stores each color in an image. For that i made this:

Code:

int pSize = 16;
PImage pal = new PImage(pSize,pSize);
color[] colors = new color[pSize*pSize];
void setup()
{
size(100,100);
setPal();
}

void draw()
{
copy(pal,0,0,pal.width,pal.height,0,0,w,h);
}

void setPal()
{
for (int i = 0; i < 64; i++)
{
colors[i] = color(i << 2,255 - ((i << 2)+1),0);
colors[i+64] = color(255,(i << 2) + 1,0);
colors[i+128] = color(255 - ((i << 2) + 1),255 - ((i << 2) + 1),0);
colors[i+192] = color(0,(i << 2) + 1,0);
pal.pixels[i] = colors[i];
pal.pixels[i+64] = colors[i+64];
pal.pixels[i+128] = colors[i+128];
pal.pixels[i+192] = colors[i+192];
}
}


Now, does anybody have an idea on how i could make a palette with random colors, rather than the same colors each time.. and it has to be fading in and out of each color, like in the code i have..

thanks in advance for any ideas Smiley

-seltar
Re: Smooth Palette Generator?
Reply #1 - Jul 31st, 2005, 10:44pm
 
Here I tried this:
http://mkv25.net/applets/seltar_palette/

The description in the PDE is something along the lines of:
Quote:
This colour palette generator is based off the idea/suggestion by Seltar. Its a bit crude but the effect should be apparent - it generates a random palette with smooth colour bands.

I've set it to generate 256 colours in 4 colour bands. Each band has a random start and end colour. The method chosen to pick these two colours is the most important factor determining the look of the palette. ...

Once the start and target colours are picked, the fade(int, int, float) method is used to generate the transitional states. ...
Re: Smooth Palette Generator?
Reply #2 - Aug 1st, 2005, 9:29am
 
Genius man Cheesy It worked like a charm, allthough it doesn't fade over from the endcolor to the next startcolor, but that doesn't really matter.. it looked good the way i intend to use it, so thank you so much Wink
I'll post the link when i finish it Wink
-seltar
Re: Smooth Palette Generator?
Reply #3 - Aug 1st, 2005, 12:21pm
 
one of th 1st things i ever made with P5 was a multi colour gradient generator class. it allows you to create arbitrarily smooth/long palettes. you can see it in action here:

http://toxi.co.uk/p5/gradient/

click to recreate, move mouse to scroll gradient...
Re: Smooth Palette Generator?
Reply #4 - Oct 5th, 2005, 9:29pm
 
Anyone have any suggestions for radial gradients?
Re: Smooth Palette Generator?
Reply #5 - Oct 6th, 2005, 7:33pm
 
Radial gradients are just a representational issue. The Gradient class in my example above is an abstract gradient definition. Instead of drawing lines, you'd draw concentric circles or measure the distance of each pixel from the gradient's origin. The distance/radius defines the current position in the gradient...

I've made a 2 minute change to the existing code (mainly the draw() method) to get it radial. click anywhere to regenerate.

http://toxi.co.uk/p5/gradientR/
Page Index Toggle Pages: 1