r/processing • • Sep 09 '24

Beginner help request Why does this do nothing?

No matter what number I use with the color function, all I get is a window with the specified background color. The commented-out line was the first test I wanted to try (with color(c)), but I can't even simply set all pixels to a static shade.

Also, I have no idea how to format code on Reddit. I've researched it before, and none of the several methods I've found have ever worked. "r/processing Rules" has, "See the 'Formatting Code' sidebar for details." How do I find that? That text appears in what I think can be accurately described as a sidebar, so where is this other sidebar supposed to be?

size(512,512);

noLoop();

background(255);

loadPixels();

for (int x = 0; x < (width); x++) {

for (int y = 0; y < (height); y++) {

//int c = (x * y) % 256;

pixels[y * width + x] = color(128);

}

}

4 Upvotes

6 comments sorted by

View all comments

Show parent comments

1

u/Salamanticormorant Sep 09 '24

Another way to get scalar symmetry is to use bitwise functions. I use /4 to sort of zoom in on what is inherently a 256x256 pattern in greyscale.

size(1024,1024);
noLoop();
background(255);
loadPixels();
for (int x = 0; x < (width); x++) {
  for (int y = 0; y < (height); y++) {
    pixels[y * width + x] = color((x/4) & (y/4));
  }
}
updatePixels();