Hallo! Can you explain me why my text doesn't spinning?

PFont myFont;

String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;

float z=random(TWO_PI);
float x;
float y;

//float rotX,rotY,rotZ;

float r = 100;
float angVel = -TWO_PI / 360;
float ang;

void setup() {
  size(800, 800, P3D);
  background(255);
  myFont = createFont("DrukTextWide-Heavy.ttf", 20);
  //textFont(myFont);
frameRate(20);

  
}

void draw() {
background(255);



rotate(ang);
  ang += angVel;
  
  float arclength = 0.4;
  for (int i = 0; i < s1.length (); i ++ ) {
    char currentChar = s1.charAt(i);
    float w = textWidth(currentChar);
    arclength += w/2;
    float theta = PI + arclength / r;
arclength += 0.2;

i=s1.length();
printQuote();
}}

void printQuote(){
  
  //camera(70,30,z,120,50,50,0,0,1);
  
int  cntX = width/2, cntY =0;
for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
 
 
// rotX += 0.0003;
 // rotY += 0.0005;
 // rotZ += 0.0007;
 
  pushMatrix();
 //rotateX(rotX);
 // rotateY(rotX);
  //rotateZ(rotX);
  
 translate(letterX, 300, letterY);
 textSize(20);
 fill(0, 0, 0);
 text(s1.charAt(j),0,0);
  popMatrix();
      
}
//z+=0.1;
}

You have one Rotation like planets around the sun in the function printQuote

Then you have one rotation ang before the for loop

Which one doesn’t work? The latter?

In the for loop in draw() you have a lot of angles but you never use them - maybe this is the problem?

In 3D there is rotateX, rotateY and rotateZ for the different axis x,y,z

With a plane you call them yaw roll and pitch

Try rotateX or rotateZ or rotateY here

Oh I fixed it! it’s the r in rotateY
thank you!!! :smile:

hmm but if i want to spinning only the text… what do you recomend

recommend*… and can you please tell me about the yaw roll and pitch?
it’s like functions for rotation

Yeah in the function add something to the angles you use for cos and sin. Increase this something.

About yaw roll pitch - Google Search google it. It’s like with a plane it can rotate around one of the 3 axis. You can tilt your letter circle left/right or front / backside (or both) or/and around y axis as well

i think it’s about int cntY =0, cntX =width/2; this function when i add
int cntY =0, cntX =width/20; look it’s in the middle but how can i take it in the center???=/

cnt is about the center in x and z (depth) direction

Height of the circle is 300 in the translate line in the function printQuote

Just change the values to find out. The function printQuote is your core code section where the important parts happen. I am not at home right now and can’t do it for you.

Did you do this? It makes the letter travel around the sun like planets do around the sun

Your descriptions are also unclear for me sometimes

What exactly do you want to achieve?

Chrisir

different motions with this string of letters!

for example now I want to make the text spinning random in this code

final static int R = 1000;
float u, v;
float[][] stars;



PFont myFont;
String s1= ("OBECALP PHARMACY ");



int i, cntX, cntY; 
float letterX, letterY;
int radius = 260;
float angleSpeed = TWO_PI/s1.length();
float x, y;



void setup()
{
  size(800, 800, P3D);
  frameRate(30);
 // sphereDetail(1);
  myFont=createFont("Monaco", 14);
  stars = new float[1000][3];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  i = s1.length(); 
  printQuote();
}

void printQuote() { 
  
int cntX = width/2, cntY = 0;

  for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);


  
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width  / 2.0) / width  / 20;
  
  
  background(0);
  //lights();
//  camera(0, 0, 0, 0, 0, R, 0, 1, 0);
  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
       
    translate(stars[i][0], stars[i][1], stars[i][2]);
    
   
    popMatrix();
  }
  { pushMatrix();
  translate(letterX, 550, letterY);
  fill(0);
    text(s1.charAt(j),0,0);
    popMatrix();
  }
  camera();
  stroke(255);
  line(width / 2 - 5, height / 2 - 0, width / 2 + 4, height / 2 + 0);
  line(width / 2 - 0, height / 2 - 5, width / 2 + 0, height / 2 + 4);
  
}}

void mousePressed() { u = v = 0; } 

I saw this amazing code and I want to add my text with rotation

final static int R = 1000;
float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);
  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));
  stars = new float[1000][3];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width  / 2.0) / width  / 20;
  background(0);
  lights();
  camera(0, 0, 0, 0, 0, R, 0, 1, 0);
  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
    translate(stars[i][0], stars[i][1], stars[i][2]);
    sphere(5);
    popMatrix();
  }
  camera();
  stroke(255);
  line(width / 2 - 5, height / 2 - 0, width / 2 + 4, height / 2 + 0);
  line(width / 2 - 0, height / 2 - 5, width / 2 + 0, height / 2 + 4);
  text("u: " + int(degrees(u)) + " v: " + int(degrees(v)), 5, 17);
}

void mousePressed() { u = v = 0; } 

I am sure you can do it

I am not at home now and can’t help you

ok thank you anyway!

1 Like

if you want to help me… because I used so many functions but I don’t know how to do it… =/
I want to have this 3D space and with my random text(// text(s1.charAt(j),0,0):wink: spinning around

PFont myFont;
String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;


float angVel = -TWO_PI / 560;
float ang;




final static int R = 1000;
float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);
  
    myFont = createFont("Serif-48.ttf", 20);
 // textFont(myFont);
 

  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));
  stars = new float[1000][5];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}




void draw()
{
  
  
  rotate(ang);
  ang += angVel;
  


i=s1.length();
printQuote();
}
  void printQuote(){
    int  cntX = width/2, cntY =0;
    
for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
 

  
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width  / 2.0) / width  / 20;
  background(0);


  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
    translate(stars[i][0], stars[i][1], stars[i][2]);
   sphere(3);
    translate(letterX, 300, letterY);
    textSize(20);



// text(s1.charAt(j),0,0);



    popMatrix();
  }
  camera();
  stroke(255);

}

  }


void mousePressed() { u = v = 0; } 

sorry! (maybe I have to sleep! haha )

PFont myFont;
String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;


float angVel = -TWO_PI / 560;
float ang;




final static int R = 1000;
float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);
  
    myFont = createFont("Serif-48.ttf", 20);
 // textFont(myFont);
 

  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));
  stars = new float[1000][5];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}




void draw()
{
  
  
  rotate(ang);
  ang += angVel;
  


i=s1.length();
printQuote();
}
  void printQuote(){
    int  cntX = width/2, cntY =0;
    
for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
 

  
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width  / 2.0) / width  / 20;
  background(0);


  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
    translate(stars[i][0], stars[i][1], stars[i][2]);
   sphere(3);
    translate(letterX, 300, letterY);
    textSize(20);



// text(s1.charAt(j),0,0);



    popMatrix();
  }
  camera();
  stroke(255);

}

  }


void mousePressed() { u = v = 0; } 

Also try draw() with these lines (they are commented out in the long code below)

   rotate(ang);
   ang += angVel;

Chrisir

Full sketch:

// PFont myFont;
String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX, letterY;
// int i;
int cntX, cntY;
int radius =260;

float angVel = -TWO_PI / 560;
float ang;
int j=0;

final static int R = 1000;

float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);

  //  myFont = createFont("Serif-48.ttf", 20);
  // textFont(myFont);

  //  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));

  // makes things slow but looks better:
  textMode(SHAPE);

  textSize(20);

  stroke(255);

  stars = new float[1000][5];
  for (int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  background(0);

  //  rotate(ang);
  // ang += angVel;

  //i=s1.length();
  printQuote();
}

void printQuote() {
  //  int  cntX = width/2, cntY =0;

  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width  / 2.0) / width  / 20;

  rotateX(u); 
  rotateY(v);

  for (int i = 0; i < stars.length; i++)
  {
    translate(stars[i][0], stars[i][1], stars[i][2]);
    text(s1.charAt(j), 0, 0);
    translate(-stars[i][0], -stars[i][1], -stars[i][2]);

    j++; 
    if (j>=s1.length())
      j=0;
  }//for
}//func 

void mousePressed() { 
  u = v = 0;
}

Now it stops spinning but it’s in the center haha now can i do to spinning =/

PFont myFont;

String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;

float z=random(TWO_PI);
float x=0;
float y;
float r =0;




float angle,c,x1,y1=0;
float speed = 0;
int waveStrengthHorizontal= 5;
int waveStrengthVertical= 5;

float u,v;
void setup() {
  size(800, 800, P3D);
  background(255);
  myFont = createFont("DrukTextWide-Heavy.ttf", 20);
  //textFont(myFont);
frameRate(20);
}

void draw() {
background(255);


i=s1.length();
printQuote();
}

void printQuote(){
  
 
  
int count =0;
for(y=0; y<500; y++){
if(count%10==0)
  {
  
int  cntY =0, cntX =width/2;
for (int j = 0; j < i; j++) 

{
    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
    
    
     
          
pushMatrix();

//rotateY(r);
//rotateX(200);

 translate(letterX, cntY, letterY);
 textSize(20);
 
 fill(0, 0, 0);
 text(s1.charAt(j),x,y);
 

  popMatrix();
  
}
}
count++;
//r=r+0.0001; angle+=10;
//speed=0.01;
  }
}