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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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);
}

chevron_right


Output:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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);
}

chevron_right


Output:

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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.