/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.oDgArMDdyoD/rev.480
*
* authors:
* frederic.vernier
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
PImage bg;
int t =0;
void setup() { // this is run once.
// canvas size (Variable aren't evaluated. Integers only, please.)
size(512, 512);
// limit the number of frames per second
frameRate(2);
bg = createImage(width, height, RGB);
}
void draw() {
// set the background color
background(128); t++;
int[] freqs = new int[1024];
for (int i=0; i<256; i++)
freqs[i]=10;
for(int j=0; j< bg.height/2; j++) {
for(int i=0; i< bg.width/2; i++) {
int c = int(random(0, 255));
freqs[c]++;
bg.pixels[i+j*width] = color(c, c, c);
c = int(256*noise(i/64, j/64, t));
freqs[c+256]++;
bg.pixels[i+256+j*width] = color(c, c, c);
c = 255-int(sqrt(sqrt(random(0, 256*256*256*256-1))));
freqs[c+256+256]++;
bg.pixels[i+(j+256)*width] = color(c, c, c);
c = int(sqrt(sqrt(random(0, 255)*random(0, 255)*random(0, 255)*random(0,255))));
freqs[c+256+256+256]++;
bg.pixels[i+256+(j+256)*width] = color(c, c, c);
}
}
image(bg, 0 ,0);
stroke(0, 255, 0);
for (int i=0; i<256; i++) {
line(i, height/2-freqs[i]/10, i, height/2);
line(i+256, height/2-freqs[i+256]/10, i+256, height/2);
line(i, height-freqs[i+256+256]/10, i, height);
line(i+256, height-freqs[i+256+256+256]/10, i+256, height);
}
}