void setup() {
size(200, 100);
noSmooth();
}
void draw() {
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
float r = random(256);
float g = random(256);
float b = random(256);
stroke(r, g, b);
point(x, y);
}
}
}
This code uses a nested for
loop to loop over every pixel in the window. For each pixel, it creates a random color and draws a point with that color at that pixel.
See the Pen by Happy Coding (@KevinWorkman) on CodePen.
noise()
function to come up with a shade of gray for each pixel. Read more about Perlin noise for more info.This example uses nested for loops to make every pixel a random color.
Happy Coding is a community of folks just like you learning about coding.
Do you have a comment or question? Post it here!
Comments are powered by the Happy Coding forum. This page has a corresponding forum post, and replies to that post show up as comments here. Click the button above to go to the forum to post a comment!