# Redeclaration of createShape in draw()

**URL:** https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498
**Category:** Processing for Android
**Created:** [July 30, 2021, 2:22pm UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498 "2021-07-30T14:22:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![paturn](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@paturn](https://discourse.processing.org/u/paturn)
#### Post date: [July 30, 2021, 2:22pm UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498/1 "2021-07-30T14:22:50Z")

</div>

I am creating a sphere shape in setup following noStroke() so there are no triangles visible on the sphere. I am then displaying images on the globe, together with a grid pattern. Under certain circumstances, I would like to display the triangles, but if I redeclare createShape(SPHERE, 500) in draw() it creates a very dark image on the globe and the image wrapped on the globe is not visible. I have background(0) before the redeclaration.  
Is it possible to redeclare createShape without causing the black out of the globe?

---

<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: [July 31, 2021, 10:02pm UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498/2 "2021-07-31T22:02:26Z")

</div>

Hello,

A _ **minimal** _ example of your [formatted](https://discourse.processing.org/faq#format-your-code) code would help.

Example at end of this tutorial was used:  
[https://processing.org/tutorials/pshape/](https://processing.org/tutorials/pshape/)

In `draw()` I selected one of these before displaying the shape:

```auto
  globe.setStroke(color(255, 255, 0));
  //globe.setStroke(0); //transparent stroke

```

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a692b0f88e6b1143fefec811bcacf968c2041151.png)

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f97a7553f75489b4617e07265dce56e3d07023d4.png)

I also had to add this to example:  
`size(300, 300, P3D);`

References:  
[https://processing.org/reference/PShape.html](https://processing.org/reference/PShape.html)

`:)`

---

<div class="post-metadata">

### Author: ![paturn](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@paturn](https://discourse.processing.org/u/paturn)
#### Post date: [August 1, 2021, 3:33am UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498/3 "2021-08-01T03:33:56Z")

</div>

Thank you glv. I’ll try that when I get back later today.

Regards  
Peter Turner

---

<div class="post-metadata">

### Author: ![paturn](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@paturn](https://discourse.processing.org/u/paturn)
#### Post date: [August 1, 2021, 8:20am UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498/4 "2021-08-01T08:20:22Z")

</div>

I had tried this previously, but initially noStroke() before declaring createShape resulted in still no stroke for both options. Even adding globe.setStrokeWeight(2); didn’t make them appear. Only by removing the initial noStroke(); does the stroke appear when calling globe.setStroke(255,255,0);

I assume that the initial noStroke() is permanent, and is not altered by subsequent calls to globe setStroke.

Thank you for your information, glv.

Regards  
Peter Turner

---

<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: [August 1, 2021, 11:23am UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498/5 "2021-08-01T11:23:06Z")

</div>

> [@paturn](#):
>
> I assume that the initial noStroke() is permanent, and is not altered by subsequent calls to globe setStroke.

It seems so.  
This one is in my notes. `:)`

And you are welcome!

An example without the texture for the topic:

```auto
PShape globe;
boolean toggle = true;
  
void setup() 
  {
  size(300, 300, P3D);
  //noFill();
  fill(128);
  // noStroke(); //Once set you can't use setStroke();
  globe = createShape(SPHERE, 100);
  println("Press a key to toggle setStroke()");
  }
  
void draw()
  {
  background(0);
  translate(width/2, height/2);
  rotateY(frameCount*TAU/360);
  
  if(toggle)
    globe.setStroke(color(255, 255, 0)); //yellow
  else
    globe.setStroke(0); // 0 is the same as color(0, 0, 0, 0) and transparent
  
  shape(globe,0, 0);
  }
  
void keyPressed()
  {
  toggle = !toggle;
  }

```

References:  
[PShape / Processing.org](https://processing.org/tutorials/pshape/) See last section for 3D and textures.  
[https://processing.org/reference/PShape.html](https://processing.org/reference/PShape.html)  
[https://processing.org/reference/color\_.html](https://processing.org/reference/color_.html)

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [August 1, 2021, 4:13pm UTC](https://discourse.processing.org/t/redeclaration-of-createshape-in-draw/31498/6 "2021-08-01T16:13:07Z")

</div>

![Untitled 212](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0a1d3c5a915cbe184a9a8ae06cbe82f641ee2eb0.jpeg)

 ![Untitled 213](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/31a266a29c01a49931cd7b3dc1785b5266cc0e5f.jpeg)

 ![Untitled 214](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2c2ac4c8989d9af8535bab6f36efa4316056a2f7.jpeg)
