True/False / Examples (2024)

Examples+

A Boolean variable has only two possible values: true or false. It is common to use Booleans with control statements to determine the flow of a program. In this example, when the boolean value "x" is true, vertical black lines are drawn and when the boolean value "x" is false, horizontal gray lines are drawn.

Highlighted Features

/** * True/False. * * A Boolean variable has only two possible values: true or false. * It is common to use Booleans with control statements to * determine the flow of a program. In this example, when the * boolean value "x" is true, vertical black lines are drawn and when * the boolean value "x" is false, horizontal gray lines are drawn. */ boolean b = false;size(640, 360);background(0);stroke(255);int d = 20;int middle = width/2;for (int i = d; i <= width; i += d) { if (i < middle) { b = true; } else { b = false; } if (b == true) { // Vertical line line(i, d, i, height-d); } if (b == false) { // Horizontal line line(middle, i - middle + d, width-d, i - middle + d); }}

This example is for Processing 4+. If you have a previous version, use the examples included with your software. If you see any errors or have suggestions, please let us know.

True/False / Examples (2024)
Top Articles
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 6306

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.