If I want to show only 1 time my text what can I use?

#1
 PFont myFont;
 float rotateVal=0.4;
 String s1= ("test");
 
 
 
 float x,y,z;
void setup(){
  background(255);
  size(500,500,P3D);
 myFont = loadFont("Serif-48.vlw");

//frameRate(20);


}

void draw(){
  
  


  
  
  pushMatrix();
 // pointLight(255,0,0,width/2,height/2,200);
  translate(100,100);
 rotateY(rotateVal);
 rotateX(x +=0.05);
textSize(100);
fill(0);

 
text(s1,x/4,rotateVal);
 
popMatrix();

}
0 Likes

#2

At the end of draw you can set a boolean firstTime to false

before your text check if(firstTime) {…

}

before setup ()

boolean firstTime = true;

0 Likes

#3

Alternatively use a timer that sets firstTime to false

if(millis()-timer) > 880) firstTime = false;

That would display the text a bit longer

0 Likes

#4

before my text you mean for void draw() ?
v=can you please explain it ? =p

0 Likes

#5

Inside draw the if clause is around the text section to not show it when firstTime is false

0 Likes

#6

See if in the reference

0 Likes

#7
 PFont myFont;
 float rotateVal=0.4;
 String s1= ("test");
 color a= color(0,10);

 
float firstTime;
int timer;
 float x,y,z;

   
void setup(){
  background(255);
  size(500,500,P3D);

 myFont = loadFont("Serif-48.vlw");


firstTime =millis();

}

void draw(){
  


  if(millis()-timer) > 880) firstTime = false;
  
  pushMatrix();

 // pointLight(255,0,0,width/2,height/2,200);
  translate(100,100);
 rotateX(rotateVal);
 rotateX(x +=0.05);
textSize(100);
fill(a);
alpha(a);
 
text(s1,x,rotateVal,width,height/2);

popMatrix(); 
}
0 Likes

#8

what am I doing wrong!!! I tried and something miss it. I guess!
Sorry I am trying to figure it out but I think I am lost in translation =p

0 Likes

#9

you need background at start of draw()

several changes below

PFont myFont;
float rotateVal=0.4;
String s1= "test";
color a= color(0);

boolean firstTime = true; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

int timer; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

float x, y, z;

void setup() {
  size(500, 500, P3D);
  background(255);

  myFont = createFont("Serif-48.vlw", 14);
  textSize(100);
  fill(a);

  timer = millis(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}

void draw() {

  background(255);


  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  if (firstTime) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    text(s1, 200, 200 );
  } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  if (millis()-timer > 880) {
    firstTime = false;
  }
}
0 Likes

#10

For an animation you need to have background () at start of draw ()

Maybe I misunderstood you. I thought you meant to show a text at startup that them disappears for good

Maybe you were referring to animation. Then your code is valid just use background

0 Likes

#11

yes it’s the background hahah thank you very much!
And If i want to rotate from different directions I use the rotateX, rotateY yes?

0 Likes

#12

that’s right

Apologies that I misunderstood you first!

PFont myFont;
float rotateVal=0.4;
String s1= "test";

color a= color(0);  // black 
color b= color(255, 2, 2); //red 
color c= color(2, 2, 255); //blue

float x, y, z;

void setup() {
  size(1500, 500, P3D);
  background(255);

  myFont = createFont("Serif-48.vlw", 19);
  textFont( myFont );
  textMode(SHAPE);
}

void draw() {
  background(255);

  // floor 
  float yValueFloor = height;
  // show floor 
  checkeredFloor(yValueFloor);

  pushMatrix();
  // pointLight(255,0,0,width/2,height/2,200);
  translate(100, 100);
  rotateX(rotateVal);
  rotateX(x +=0.05);
  textSize(100);
  fill(a);
  alpha(a);
  text(s1, x, rotateVal, width, height/2);
  popMatrix();

  pushMatrix();
  // pointLight(255,0,0,width/2,height/2,200);
  translate(700, 300);
  rotateY(rotateVal + (x +=0.05));
  textSize(100);
  fill(b);
  //alpha(a);
  textAlign(CENTER);
  text(s1, 0, 0);
  textAlign(LEFT);
  popMatrix();

  pushMatrix();
  translate(1200, 300, z);
  rotateZ(rotateVal + (x +=0.05));
  textSize(100);
  fill(c);
  textAlign(CENTER);
  text(s1, 0, 0);
  textAlign(LEFT);
  z--;
  popMatrix();
}

void checkeredFloor(float yValueFloor) {

  noStroke();

  for (int i = 0; i < 50; i = i+1) {
    for (int j = -40; j < 42; j = j+1) {

      // % is modulo, meaning rest of division 
      if (i%2 == 0) { 
        if (j%2 == 0) { 
          fill (255, 0, 0);
        } else 
        {
          fill ( 103 );
        }
      } else {
        if (j%2 == 0) { 
          fill ( 103 );
        } else 
        {
          fill (255, 0, 0);
        }
      } // if

      pushMatrix();
      translate ( 80*i-610, yValueFloor, 80*j-940 );
      box ( 80, 7, 80);  // one cell / tile 
      popMatrix();
    } // for
  } // for
} // function
0 Likes