Sunday, December 29, 2024
Google search engine
HomeLanguagesJavascriptp5.js bezierDetail() function

p5.js bezierDetail() function

The bezierDetail() function in p5.js is used to set the resolution at which Beziers display. In order to use it we must use WEBGL render parameter.

Syntax:

bezierDetail( detail )

Parameters: The function accepts single parameter detail which stores the resolution of the curves.

Below programs illustrate the bezierDetail() function in p5.js:

Example 1: This example uses bezierDetail() function to set resolution at which Beziers display.




function setup() {
  
    // Create canvas size
    createCanvas(450, 310, WEBGL);
      
    // bezierDetail() function
    bezierDetail(6);
}
  
function draw() {
  
    // Set the background color
    background(220);
    noFill();
      
    // Bezier function with 8 parameters 
    // except z-coordinate
    bezier(85, 20, 10, 10, 160, 90, 50, 80);
}


Output:

Example 2: This example uses bezierDetail() function to set resolution at which Beziers display.




function setup() {
      
    // Create canvas of given size
    createCanvas(350, 350, WEBGL);
      
    // Use bezierDetail function
    bezierDetail(4);
}
  
function draw() {
      
    // Set background color
    background(0, 0, 0);
      
    noFill();
      
    // Set stroke color
    stroke(255);
      
    // Draw bezier curve
    bezier(150, 50, 0, 100, 100, 0, 100, 0, 0, 0, 100, 0);
}


Output:

Reference: https://p5js.org/reference/#/p5/bezierDetail

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen 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!

RELATED ARTICLES

Most Popular

Recent Comments