p5.js boolean() function Last Updated : 22 Aug, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The boolean() function in p5.js is used to convert the given string and number value into its boolean representation. Syntax: boolean(Value) Parameters: This function accepts single parameter Value which are to be converted into its boolean representation. This value might be integer, float, string, boolean, negative or positive value and array of values. Return Value: It returns the converted boolean representation. Below program illustrates the boolean() function in p5.js: Example 1: This example uses boolean() function to convert input value into its boolean value. javascript function setup() { // Creating Canvas size createCanvas(600, 200); } function draw() { // Set the background color background(220); // Initializing some values let Value1 = 12; let Value2 = 12.5; let Value3 = -7.9; let Value4 = -6; let Value5 = "6"; let Value6 = 0; // Calling to boolean() function. let A = boolean(Value1); let B = boolean(Value2); let C = boolean(Value3); let D = boolean(Value4); let E = boolean(Value5); let F = boolean(Value6); // Set the size of text textSize(16); // Set the text color fill(color('red')); // Getting boolean representation text("Boolean representation of value 12 is: " + A, 50, 30); text("Boolean representation of value 12.5 is: " + B, 50, 60); text("Boolean representation of value -7.9 is: " + C, 50, 90); text("Boolean representation of value -6 is: " + D, 50, 110); text("Boolean representation of string '6' is: " + E, 50, 140); text("Boolean representation of string 0 is: " + F, 50, 170); } Output: Example 2: This example uses boolean() function to convert input value into its boolean value. javascript function setup() { // Creating Canvas size createCanvas(600, 140); } function draw() { // Set the background color background(220); // Initializing some values let Value1 = true; let Value2 = false; let Value3 = "Geeks"; let Value4 = [12, 3.6, -9.8, "true", false, "Geeks"]; // Calling to boolean() function. let A = boolean(Value1); let B = boolean(Value2); let C = boolean(Value3); let D = boolean(Value4); // Set the size of text textSize(16); // Set the text color fill(color('red')); // Getting boolean representation text("Boolean representation of value 'true' is: " + A, 50, 30); text("Boolean representation of value 'false' is: " + B, 50, 60); text("Boolean representation of value 'Geeks' is: " + C, 50, 90); text("Boolean representation of array of values are: " + D, 50, 110); } Output: Note: From the above examples, If the parameter is non-zero value then it returns true and for strings, only "true" string returns true otherwise it returns false output for any other string. Reference: https://p5js.org/reference/#/p5/boolean Comment More infoAdvertise with us Next Article PHP | boolval() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Similar Reads p5.js byte() function The byte() function in p5.js is used to convert the given string of number, number value or boolean into its byte representation. This byte number can only be whole number in between -128 to 127. The value outside of the range is converted into its corresponding byte representation.Syntax:  byte(Va 3 min read PHP | boolval() Function The boolval() function is an inbuilt function in PHP which gives the Boolean value for a given expression. Syntax: boolean boolval( $expr ) Parameter: This function accepts only one parameter as shown in above syntax and described below: $expr: The expression or the scalar which you want to change i 3 min read PHP | boolval() Function The boolval() function is an inbuilt function in PHP which gives the Boolean value for a given expression. Syntax: boolean boolval( $expr ) Parameter: This function accepts only one parameter as shown in above syntax and described below: $expr: The expression or the scalar which you want to change i 3 min read Less.js Logical boolean() Function Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is a dynamic style sheet language that improves CSS's functionality. Cross-browser interoperability is supported by LESS. A scripting language known as CSS pre- 3 min read p5.js createCheckbox() Function The createCheckbox() function in p5.js is used to create a checkbox element in the DOM (Document Object Model). This function includes the p5.dom library. Add the following syntax in the head section. html <script src= "https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js" 1 min read p5.js noTint() Function The noTint() function is used to remove the fill value for images that has been previously applied using the tint() function. It will revert the tint of the images and display them with their original hues. Syntax: noTint() Parameters: This function does not accept any parameters. Below examples ill 2 min read Like