Hi there,
I’m very new to processing and I was wondering if there’s a better way to write this IF statement. What I’m doing is creating a drawing tool and want to confine the line to a space in the window. This statement works but I’m guessing there’s a cleaner way to write this out and would love to know how.
if(condition){
someCode();
}
if(condition)someCode();
//note this is best kept to single instructions for the condition as it can fail if you chain more than one instruction and you would then have to encapsulate everything in {}
A traditional if-else construct in C, Java and JavaScript is written:
One thing you might think of is in fame number ‘fn’ mouseX > margin && mouseX < width - margin && mouseY > margin && mouseY < width - margin
is the same as this pmouseX > margin && pmouseX < width - margin && pmouseY > margin && pmouseY < width - margin
in frame no ‘fn + 1’
So if you have 2 global boolean variables curr and last then this should work