Sha256: a060afac1574b3ae1e7713023bf74fdaa6b933b577bb6eb2a00a0067e6a3583f

Contents?: true

Size: 992 Bytes

Versions: 10

Compression:

Stored size: 992 Bytes

Contents

# 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. 


def setup
  
  size 640, 360  
  background 156
  
  op = false
  
  (5...width).step(5) do |i|
    
    stroke 0
    
    # Logical AND
    
    if (i > 35) && (i < 100)
      
      line width / 4, i, width / 2, i
      op = false
    end
    
    stroke 76
    
    # Logical OR
    
    if (i <= 35) || (i >= 100)
      line width / 2, i, width, i
      op = true
    end
    
    
		# Testing if a boolean value is "true"
		# The expression "if op" is equivalent to "if (op == true)"
		
		if op
		  stroke_weight 2
		  stroke 0
		  point width / 3, i
		end
		
		# Testing if a boolean value is "false"
		# The expressions "unless op" or "if !op" are equivalent to "if (op == false)"
		
		unless op
		  stroke_weight 3
		  stroke 255
		  point width/4, i
		end
		stroke_weight 1
	end
	
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.6.2 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.6.1 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.6.0 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.5.1 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.5.0 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.4.4 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.4.3 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.4.2 samples/processing_app/basics/control/logical_operators.rb
ruby-processing-2.4.1 samples/processing_app/basics/control/logical_operators.rb