# Why can't I set PShape's stroke with P2D

**URL:** <https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859>\
**Category:** Coding Questions\
**Created:** [January 26, 2019, 2:29pm UTC](https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859 "2019-01-26T14:29:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kikinnaz](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kikinnaz](https://discourse.processing.org/u/kikinnaz)\
**Post date:** [January 26, 2019, 2:29pm UTC](https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859/1 "2019-01-26T14:29:00Z")

</div>

Hi everyone,  
I was wondering whether I overlooked an important piece of information or whether it is a bug. When I create my PShape and set it a stroke color, it is completely ignored when using P2D and I cannot find a way to change that color in any way.

This is how I create my shape

```auto
    PShape pshape = createShape();
    pshape.beginShape();
    
    for (Edge e : mc.orderedEdges) {
      pshape.vertex(e.A.x, e.A.y);
    }

    pshape.noFill();
    pshape.stroke(255);
    pshape.strokeWeight(0.2);
    pshape.endShape();

```

When I then display it using `shape(pshape)` with `setup(2000, 1000)`, the shape is drawn in white stroke, but if I run the program with `setup(2000, 1000, P2D)`, it is black. And even if I comment out the assignment of the stroke to the pshape and just set the stroke to white before calling `shape(pshape)`, it doesn’t work.

To be honest, I am constantly confused about what works with P2D and what doesn’t, concerning PShapes.

If anyone can help me understand, I would be grateful 😉

---

<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:** [January 27, 2019, 4:43am UTC](https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859/2 "2019-01-27T04:43:43Z")

</div>

- -a- it can help if you show a working code

- -b- for “error” reporting pls give info for your working environment

- -c- for your question about renderer:  
i try

```auto
  size (200, 200); // test also P2D P3D same

```

no difference.

```auto
// https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859

// test shape Raspberry Pi 3B+, 
// OS: Raspbian,
// Processing IDE 3.5.2,

PShape myshape;
boolean myfill= false, mystroke=false;

void setup() {
  size (200, 200); // test also P2D P3D same
  make_myshape();
  println("use: key [m][s][f]");
}

void make_myshape() {
  myshape = createShape();
  myshape.beginShape();
  myshape.fill(0, 200, 0);
  myshape.stroke(200, 0, 0);
  myshape.strokeWeight(3);    
  for (int i =0; i<3; i++) myshape.vertex(random(-100,100), random(-100,100));
  myshape.endShape(CLOSE);
}

void draw() {
  background(200, 200, 0);
  shape(myshape, width/2, height/2);
}

void keyPressed() {
  if ( key == 'm' ) make_myshape(); 
  if ( key == 's' ) { 
    mystroke = ! mystroke;
    if ( mystroke ) myshape.setStroke(color(200, 200, 200));
    else myshape.setStroke(color(0, 200, 200));
  }
  if ( key == 'f' ) {
    myfill = ! myfill;
    if ( myfill ) myshape.setFill(color(0, 0, 200));
    else myshape.setFill(color(200, 0, 200));
  }
}

```

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [January 27, 2019, 6:11am UTC](https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859/3 "2019-01-27T06:11:17Z")

</div>

If i‘m not mistaken, then you can‘t set strokeWeight with a float… at least for P2D… might be because P2D prioritises speed over graphics.

---

<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:** [January 27, 2019, 7:41am UTC](https://discourse.processing.org/t/why-cant-i-set-pshapes-stroke-with-p2d/7859/4 "2019-01-27T07:41:51Z")

</div>

```auto
  myshape.strokeWeight(3.5); // test LEXYTH

```

works for all 3 renderer

but 0.2 might be nearly invisible until you use

```auto
  noSmooth();

```

in setup()

so possibly the question is not

> Why can’t i set

more

> Why can’t i see
