p5.js min() function

The min() function in p5.js is used to get the minimum value from the sequence of numbers.
Syntax:
min(a, b)
or
min(arr)
Parameters: The min(a, b) function accepts two parameters which are two different number and compared to get minimum value among them. The min(arr) function accepts a single parameter array.
Return Value: It returns the minimum value among the different numbers.
Below program illustrates the min() function in p5.js:
Example: This example uses min() function to get the minimum value.
function setup() {        // Create Canvas of size 270*80     createCanvas(350, 130); }    function draw() {            // Set the background color     background(220);            // Call to min() function     let u = min(1, 3);     let v = min(1, 1);     let w = min(5, 9);     let x = min(2, 3.9);     let y = min(1.5, 3.2);            // Set the size of text     textSize(16);            // Set the text color     fill(color('red'));          // Getting minimum value        text("Minimum value between (1, 3) is: " + u, 50, 30);     text("Minimum value between (1, 1) is: " + v, 50, 50);     text("Minimum value between (5, 9) is: " + w, 50, 70);     text("Minimum value between (2, 3.9) is: " + x, 50, 90);     text("Minimum value between (1.5, 3.2) is: " + y, 50, 110);     } |
Output:
Reference: https://p5js.org/reference/#/p5/min
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!




