mirror of
https://github.com/dyne/FreeJ.git
synced 2026-02-05 12:39:15 +01:00
processing-js 0.4 has been merged in some relevant parts basic and topic scripts added for test color handling fixed, more scripts show up now
38 lines
859 B
Plaintext
38 lines
859 B
Plaintext
float increment = 0.02;
|
|
|
|
void setup() {
|
|
size(100,100);
|
|
noLoop();
|
|
}
|
|
|
|
void draw() {
|
|
background(0);
|
|
|
|
// Optional: adjust noise detail here
|
|
// noiseDetail(8,0.65f);
|
|
|
|
loadPixels();
|
|
|
|
float xoff = 0.0; // Start xoff at 0
|
|
|
|
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
|
|
for (int x = 0; x < width; x++) {
|
|
xoff += increment; // Increment xoff
|
|
float yoff = 0.0; // For every xoff, start yoff at 0
|
|
for (int y = 0; y < height; y++) {
|
|
yoff += increment; // Increment yoff
|
|
|
|
// Calculate noise and scale by 255
|
|
//float bright = noise(xoff,yoff)*255;
|
|
|
|
// Try using this line instead
|
|
float bright = random(0,255);
|
|
|
|
// Set each pixel onscreen to a grayscale value
|
|
pixels[x+y*width] = color(bright);
|
|
}
|
|
}
|
|
|
|
updatePixels();
|
|
}
|