We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Basically when I compile my sketch it first looks and works the way it's intended (Grid of rectangles in different shades of grey, whilst mousing over one it turns black). But after a bit the entire sketch gets kind of messed up and you can see lines going from (0, 0) to the respective rectangle coordinates. I've been trying to fix it for a while and so far I've noticed that it doesn't happen when the program isn't inside the draw() function (but mouse input obviously doesn't work then, it's just a static image). Also when I change the stroke colour before each rectangle is drawn it changes the colour of the outlines going crazy as well. Tried googling but couldn't find anything, also pretty new to processing.
tl;dr: tried programming a grid of colored rectangles that change colour trough mouse input, ended up with loads of lines going haywire.
Help appreciated!
int maxRows = 10;
int maxColumns = 10;
int[][] colorValue = new int[maxRows][maxColumns];
float fieldSize = 50;
void setup() {
size(500, 500);
for (int row = 0; row < maxRows; row++) {
for (int column = 0; column < maxColumns; column++) {
colorValue[row][column] = int(random(255));
}
}
}
void draw() {
int y = 0;
for (int row = 0; row < maxRows; row++) {
int x = 0;
for (int column = 0; column < maxColumns; column++) {
if (mouseX > x && mouseX < (x + fieldSize) && mouseY > y && mouseY < (y + fieldSize)) {
fill(0);
rect(x, y, fieldSize, fieldSize);
} else {
fill(colorValue[row][column]);
rect(x, y, fieldSize, fieldSize);
x += 50;
}
}
y += 50;
}
}
Here's what it looks like (sorry, couldn't get the image option to work properly at all) http://www.imgur.com/a/0T36k
Answers
um, i had a similar problem in 3.1.1 (not 3.0) but it was later fixed
https://forum.processing.org/two/discussion/17876/problem-in-pshape-quad-strip
however, i can't reproduce the above in 3.1.1
which version are you using?
Can't reproduce in 3.2.3. If you can, update Processing to the latest version.
I had 3.2.3 installed on my laptop, tried running the code on my pc which is running version 3.0.2 and it works fine on that one, still no luck on my laptop though. Maybe just a bug with my onboard graphics?
runs fine on my PC
try updating your graphic card's driver