PShape issues with noFill()

When using PShape the noFill() method appears to be missing in action. The following code demonstrates a workaround.

Curiously, if I try the P2D renderer, I get no circles at all.

Note also the comment about setStrokeWeight(). Surely this is a bug that should be fixed?

int BLACK = 0;
int WHITE = 255;
int DENSITY = 500;

void setup() {
    size(800, 800, FX2D);
    background(WHITE);

    circler(20, 0);
    circler(60, 100);
    circler(120, 140);
    circler(180, 200);
}

void circler(float r, int c) {
    // define a shape
    PShape circlet; 

    // valid primitives: LINE, ELLIPSE, RECT, ARC, TRIANGLE, SPHERE, BOX, QUAD
    circlet = createShape(ELLIPSE, 0, 0, r, r);
    circlet.setStroke(c);

    // No support for this method? Use a trick!
    // circlet.noFill();
    circlet.setFill( color(WHITE, 0) );

    // strangely this method doesn't highlight as legal (blue)
    // also: value must be a float or it's ignored
    circlet.setStrokeWeight(6.);

    // draw
    pushMatrix();   
    translate(width/2, height/2);
    shape(circlet, 0, 0);
    popMatrix();
}
1 Like

if you check out this page you will find this

It should be noted that unlike with fill() and stroke() you must pass a full color as an argument. i.e. instead of saying “setFill(255,0,0)” for a red fill, you’ll need to say “setFill(color(255,0,0))”. In addition, setFill() and setStroke() can take a boolean argument (e.g. setFill(false)) to turn the fill or stroke on or off

i think noFill() is more for when you are using beginShape() endShape() I’ll let you figure all that out I just thought I’d point out the above. so basically your code with the change:

int BLACK = 0;
int WHITE = 255;
int DENSITY = 500;

void setup() {
    size(640, 480, P2D);
    background(255,0,255);

    circler(20, color(0, 0, 0));
    circler(60, color(100, 100, 100));
    circler(120, color(140, 140, 140));
    circler(180, color(200,200, 200));
}

void circler(float r, int c) {
    // define a shape
    PShape circlet; 

    // valid primitives: LINE, ELLIPSE, RECT, ARC, TRIANGLE, SPHERE, BOX, QUAD
    circlet = createShape(ELLIPSE, 0, 0, r, r);
    circlet.setStroke(c);

    // No support for this method? Use a trick!
    // circlet.noFill();
    circlet.setFill(false);

    // strangely this method doesn't highlight as legal (blue)
    // also: value must be a float or it's ignored
    circlet.setStrokeWeight(6.);

    // draw
    pushMatrix();   
    translate(width/2, height/2);
    shape(circlet, 0, 0);
    popMatrix();
}
1 Like