# Where is this stroke coming from?

**URL:** <https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545>\
**Category:** Coding Questions\
**Created:** [October 9, 2019, 10:56am UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545 "2019-10-09T10:56:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [October 9, 2019, 10:56am UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545/1 "2019-10-09T10:56:43Z")

</div>

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

![22](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/dc65abe0dcde7b69219d82e9f2f91d210f9964af.png)

```auto
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();
}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 9, 2019, 10:59am UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545/2 "2019-10-09T10:59:39Z")

</div>

try

```auto
  noSmooth();

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 9, 2019, 2:21pm UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545/3 "2019-10-09T14:21:22Z")

</div>

Hello,

Added background():

```auto
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/examples/creategraphics.html)  
[https://processing.org/reference/createGraphics\_.html](https://processing.org/reference/createGraphics_.html)

🙂

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [October 9, 2019, 4:46pm UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545/4 "2019-10-09T16:46:47Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 12, 2019, 6:27pm UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545/5 "2019-10-12T18:27:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 13, 2019, 9:13am UTC](https://discourse.processing.org/t/where-is-this-stroke-coming-from/14545/6 "2019-10-13T09:13:23Z")

</div>

> [@Tiemen](#):
>
> since the strokes aren’t there when you swap it with `pg.rect`

> [@jeremydouglass](#):
>
> 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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/14afae9858a4883fec35f67c73b4bc79235aefa7.png)

**With** pg.background():  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c5f29f800534d1310c56eb9e52d1cef9ec1bb4fd.png)

Code used (modified original):

```auto
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.

🙂
