p5.js | noFill() Function

The noFill() function is used to disable the filling geometry. If noStroke() and noFill() function are called simultaneously then nothing will be drawn on the screen.

Syntax:

noFill()

Parameters: This function does not accept any parameter.



Below examples illustrate the noFill() function in p5.js:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

function setup() { 
      
    // Create Canvas of given size 
    createCanvas(400, 300); 
  
function draw() { 
      
    // Set the background color 
    background(220); 
      
    // Use fill() function to fill color
    fill('green')
    // Draw a line 
    rect(50, 50, 150, 150); 
      
    // Use noFill() function
    noFill();
    
    // Draw a line 
    rect(100, 100, 150, 150); 

chevron_right


Output:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

function setup() { 
      
    // Create Canvas of given size 
    createCanvas(400, 300); 
  
function draw() { 
      
    // Set the background color 
    background(220); 
      
    // Use noFill() function
    noFill();
      
    // Draw a line 
    circle(140, 100, 150);
      
    // Use fill() function to fill color
    fill('green')
    // Draw a line 
    circle(240, 100, 150); 

chevron_right


Output:

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



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.