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:




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


Output:

Example 2:




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


Output:

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

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!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button