Planetary Painter
//red
static int r[DIM];int p=rand()%9-4;r[i]=i&r[i]?(r[i]+r[i-1])/2:i?r[i-1]:512;r[i]+=r[i]+p>0?p:0;return r[i]?r[i]<DIM?r[i]:DM1:0;
//green
static int r[DIM];int p=rand()%7-3;r[i]=i&r[i]?(r[i]+r[i-1])/2:i?r[i-1]:512;r[i]+=r[i]+p>0?p:0;return r[i]?r[i]<DIM?r[i]:DM1:0;
//blue
static int r[DIM];int p=rand()%15-7;r[i]=i&r[i]?(r[i]+r[i-1])/2:i?r[i-1]:512;r[i]+=r[i]+p>0?p:0;return r[i]?r[i]<DIM?r[i]:DM1:0;
Inspired by Martin's obviously awesome entryobviously awesome entry, this is a different take on it. Instead of randomly seeding a portion of the pixels, I start with the top left corner as RGB(512,512,512), and take random walks on each color from there. The result looks like something from a telescope (imo).
Each pixel takes the average of the pixels above/left of it and adds a bit o' random. You can play with the variability by changing the p
variable, but I think what I'm using is a good balance (mainly because I like blue, so more blur volatility gives good results).
There's a slight negative bias from integer division when averaging. I think it works out, though, and give a nice darkening effect to the bottom corner.
Of course, to get more than just a single result, you'll need to add an srand()
line to your main function.