Name

setFill()

Class

PShape

Description

The setFill() method defines the fill color of a PShape. This method is used after shapes are created or when a shape is defined explicitly (e.g. createShape(RECT, 20, 20, 80, 80)) as shown in the above example. When a shape is created with beginShape() and endShape(), its attributes may be changed with fill() and stroke() within beginShape() and endShape(). However, after the shape is created, only the setFill() method can define a new fill value for the PShape.

Examples

  • PShape circle;
    
    void setup() {  
      size(640, 360, P2D);
      circle = createShape(ELLIPSE, 0, 0, 200, 200);
      circle.setStroke(color(255));  
    }
    
    void draw() {
      background(51);
      circle.setFill(color(random(255)));
      translate(mouseX, mouseY);
      shape(circle);
    }
    
    

Syntax

  • sh.setFill(fill)

Parameters

  • sh(PShape) any variable of type PShape

Return

  • void