Where is this stroke coming from?

I get a strange grey stroke when drawing, where is it coming from?

22

PGraphics pg;


void setup() {
  size(800, 600, P2D);
  pg = createGraphics(width, height, P2D);
  pg.beginDraw();
  pg.background(255);
  pg.endDraw();
}


void draw() {
  image(pg, 0, 0);  
}


void mouseDragged() {
 pg.beginDraw();
 pg.noStroke();
 pg.fill(255);
 pg.ellipse(mouseX, mouseY, 50, 50);
 pg.endDraw();
}

try

  noSmooth();

Hello,

Added background():

void mouseDragged()
{
 pg.beginDraw();
 pg.background(255);
 pg.noStroke();
 //pg.stroke(100);
 //pg.strokeWeight(2);
 pg.fill(255);
 pg.ellipse(mouseX, mouseY, 50, 50);
 pg.endDraw();
}

References:
https://processing.org/examples/creategraphics.html
https://processing.org/reference/createGraphics_.html

:slight_smile:

Kll’s suggestion works, yet I’m still curious why the grey strokes are showing up. It seems pg.ellipse is causing it, since the strokes aren’t there when you swap it with pg.rect

Possibly your blendmode? You are antialiasing / smoothing an ellipse against a null background. Then you are copying the result onto a white background, but it looks like you are getting pixels that are pre-blended onto the null-as-black, resulting in gray. Just a quick guess.

Possibly the difference is that pg.rect doesn’t antialias when aligned to pixel units.

It is there with the rectangle rotated.

Without pg.background(255) :
image

With pg.background():
image

Code used (modified original):

PGraphics pg;
boolean pgReady = false;

void setup() 
  {
  size(400, 400, P2D);
  //noSmooth();
  pg = createGraphics(width, height, P2D);
  //pg.beginDraw();
  //pg.background(255);
  //pg.endDraw();
  }

void draw() 
  {
  background(255);
  if (pgReady) 
    image(pg, 0, 0);
  }

void mouseDragged()
  {
  pgReady = true;
  pg.beginDraw();
  pg.background(255);
  pg.noStroke();
  pg.fill(250);
  pg.rotate(TAU/100);
  pg.rect(50, 50, 150, 150);
  pg.ellipse(mouseX, mouseY, 50, 50);
  pg.endDraw();
  }

noSmooth() was not required in my example and will not give smooth() shapes if they are coded to be visible.

:slight_smile: