I am trying to use noFill() to "color" a rect "clear", that is, I want the rect to be "see through", so the images I have behind it can be seen. In my program, I have a bunch of colored rectangles in cols and rows that cover the whole display window, and as the mouse moves across the screen, a loop is comparing an array of mouse positions to the position of the rectangles covering the screen, if a match is made, the rect is noFill() - i can see through the rect - if a match is not made, the rect is filled with a solid color. I have 20 mouse position that increment with each new mouse input to make a trail effect. But it doesn't work right, when I use noFill() only 1 rect in my array ends up actually "see through", but when i specify a color with fill(), it works just fine. I have also messed with using fill() with an alpha value of "0", and this doesn't work quite right either...any help would be great!
//this is the size of each sheild unit, the smaller, the more difficult to uncover
int sheild = 20;
//this is the length of the uncover array, the bigger the number the easier to uncover the sheild
int strength = 20;
//this stops the sheild loop when a matching mouseX/Y position in the uncover array is detected
int matches = 0;
//this is the uncover array, it stores the last x mouse positions, and removes the sheild from those points
I find more readable with less empty lines between lines of code. Note: there is something worse that no comments: incorrect or misleading comments. The one at the line 14 is confusing, as the soft brace closes the q loop!
Let's analyze your loop (I haven't tried to run it, sorry if I am wrong!). You have a complex condition. While it is not meet, you display rectangles in green. Once it is OK, you can noFill, so you draw an empty rectangle and set matches to 1. BTW, if you don't plan to increment it, you should use a boolean here, less confusing with a proper name... So, once you found your condition, next q rectangles won't be displayed. Mmm, I don't see the point of overlaying opaque rectangles, now that I think of it...
Result: unless the condition is meet on the first q loop, there will be always at least one rectangle colored opaquely. Maybe you want to run your q loop and set noFill/fill after it, based on matches result. You can use a break to go out of q loop as soon as you find the proper condition.
Leave a comment on PhiLho's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic