/script>
I'm attempting to fill individual pixels of an image in a checkerboard pattern.
No matter what I do, it fails to work. My logic is wrong somewhere.
Anyone willing to take a look?public void checkerFilter() {
int r = 0;
int g = 102;
int b = 0;
int x = 0, y = 0;
int col = (r << 16) | (g << 8) | b;
for (int i = 0; i < img.getHeight(); i++) {
for (int j = 0; j < img.getWidth(); j++) {
if (x == img.getWidth()) {
x = 1;
break;
} else if (x == img.getWidth() - 1) {
x = 0;
} else {
img.setRGB(x, y, col);
x += 2;
}
}
y++
img.setRGB(x, y, col);
}
displayImage(); //displays image in jframe
}
>>57447416
forgot to mention I'm working in Java.
>>57447419
>working in Java
there's your problem
>>57447416
you gotta learn from the pros then
shadertoy.com
Does it just not work, or are you not getting the output you expect. Also, >>/dpt/.
Why are you even bothering with x and y?
Just run through j by twos starting at i % 2.
Dont fall for the java meme folks.
>>57447416
What the fuck how can someone be this dumb not being able to draw a simple checkerboard, this surely is some troll?
>>57447934
This.
>>57447934
I think he wants to regard the the checkerboard problem after he finishes drawing it by using those two variables with the interface.
>>57447416
>asking for the solution of a logical problem in programming instead of solving it
dude, this is the funniest part