Redeclaration of createShape in draw()

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?

Hello,

A minimal example of your formatted code would help.

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

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

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

image

image

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

References:
https://processing.org/reference/PShape.html

:)

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

Regards
Peter Turner

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

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

And you are welcome!

An example without the texture for the topic:

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 See last section for 3D and textures.
https://processing.org/reference/PShape.html
https://processing.org/reference/color_.html