Loading...
Logo
Processing Forum
I have created a program (shown below) which displays rotated text in motion. The text is rotated by 45 degrees 
and moves from the top left to the bottom right of the screen.

The problem is that the text, while moving, "vibrates", and this happens with the latest version
of Processing both under OS X and Windows. 

Is this an unavoidable rendering problem, or is there a way to make the text move smoothly?

Thanks for any help.
Copy code
  1. PVector position;
  2. PVector velocity;

  3. void setup() {
  4. size(700, 700);
  5.  background(255);
  6.  smooth();
  7.  position = new PVector(0,0);
  8.  velocity = new PVector(1, 0);

  9. void draw(){
  10.  background(255);
  11.  rotate(radians(45));
  12.  fill(255);
  13.  rect(position.x, position.y, 350, 75);
  14.  fill(0);
  15.  text ("text vibrating: Lorem Ipsum is simply dummy text of the printing and typesetting industry.", position.x+5, position.y+5, 350-100, 75-10);
  16.  if(out()){
  17.    position.x=0;
  18.    background(255, 255, 255);
  19.  }else{
  20.    update();
  21.  }
  22. }

  23. void update(){
  24.  position.add(velocity);
  25. }

  26. boolean out(){
  27.  if(position.x>(sqrt(pow(width,2)+pow(height,2)))/2+350){
  28.    return true;
  29.  }
  30.  return false;
  31. }

Replies(2)

Happens for me too. Might be an unavoidable rendering problem. But there IS hope:

Copy code
  1. PVector position;
  2. PVector velocity;

  3. PImage img;

  4. void setup() {
  5.   size(700, 700);
  6.   background(255);
  7.   fill(255);
  8.   rect(0,0, 350, 75);
  9.   fill(0);
  10.   text ("text vibrating: Lorem Ipsum is simply dummy text of the printing and typesetting industry.", 5, 5, 350-100, 75-10);
  11.   img = get(0,0,351,76);


  12.   background(255);
  13.   smooth();
  14.   position = new PVector(0, 0);
  15.   velocity = new PVector(1, 0);

  16. void draw() {
  17.   background(255);

  18.   rotate(radians(45));
  19.   translate( position.x, position.y );
  20.   image( img, 0, 0 );
  21.   //fill(255);
  22.   //rect(0,0, 350, 75);
  23.   //fill(0);
  24.   //text ("text vibrating: Lorem Ipsum is simply dummy text of the printing and typesetting industry.", 5, 5, 350-100, 75-10);
  25.   if (out()) {
  26.     position.x=0;
  27.     background(255, 255, 255);
  28.   }
  29.   else {
  30.     update();
  31.   }
  32. }

  33. void update() {
  34.   position.add(velocity);
  35. }

  36. boolean out() {
  37.   if (position.x>(sqrt(pow(width, 2)+pow(height, 2)))/2+350) {
  38.     return true;
  39.   }
  40.   return false;
  41. }

Thanks for your answer. Now the problem is solved.