mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Examples updates for 2.0
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
/**
|
||||
* Logical Operators.
|
||||
* Logical testerators.
|
||||
*
|
||||
* The logical operators for AND (&&) and OR (||) are used to
|
||||
* combine simple relational statements into more complex expressions.
|
||||
* The NOT (!) operator is used to negate a boolean statement.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
size(640, 360);
|
||||
background(126);
|
||||
|
||||
boolean op = false;
|
||||
boolean test = false;
|
||||
|
||||
for(int i=5; i<=195; i+=5) {
|
||||
for(int i = 5; i <= height; i += 5) {
|
||||
// Logical AND
|
||||
stroke(0);
|
||||
if((i > 35) && (i < 100)) {
|
||||
line(5, i, 95, i);
|
||||
op = false;
|
||||
line(width/4, i, width/2, i);
|
||||
test = false;
|
||||
}
|
||||
|
||||
// Logical OR
|
||||
stroke(76);
|
||||
if((i <= 35) || (i >= 100)) {
|
||||
line(105, i, 195, i);
|
||||
op = true;
|
||||
line(width/2, i, width, i);
|
||||
test = true;
|
||||
}
|
||||
|
||||
// Testing if a boolean value is "true"
|
||||
// The expression "if(op)" is equivalent to "if(op == true)"
|
||||
if(op) {
|
||||
// The expression "if(test)" is equivalent to "if(test == true)"
|
||||
if(test) {
|
||||
stroke(0);
|
||||
point(width/2, i);
|
||||
point(width/3, i);
|
||||
}
|
||||
|
||||
// Testing if a boolean value is "false"
|
||||
// The expression "if(!op)" is equivalent to "if(op == false)"
|
||||
if(!op) {
|
||||
// The expression "if(!test)" is equivalent to "if(test == false)"
|
||||
if(!test) {
|
||||
stroke(255);
|
||||
point(width/4, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user