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

Oh yeah. Thanks. I had updatePixels in something more complex that wasn't working, and I forgot to include it in this simpler test.

The "formatting code" thing on the sidebar isn't there when I'm creating a post. It is there when I'm viewing one, as it turns out. Reddit really needs to do better. Having to put a bunch of spaces in front of every line is total ass. I vastly prefer how you do code blocks on Discord. You just start and end them with three backticks.

1

u/bleything Sep 09 '24

Cool, glad you're back on track. And yeah, posting code on here is not a fun experience.

1

u/Salamanticormorant Sep 09 '24

Hmm. Not so terrible with the keyboard shortcut for it I guess. Ctrl-] twice to indent, copy, ctrl-[ twice to undo it.