top of page
Marble Surface

CODE 2

PFont f;
String message = "Yann";
float theta, deg;
 
void setup() {
  size(600, 600);
  // fullScreen();
  f = createFont("SentyWen",60,true);
}
 
void draw() { 
  background(213,345,333);
  fill(0);
  textFont(f);     
  translate(width/2,height/2);   
  rotate(theta);                   
  // rotate(radians(deg)); 
  textAlign(CENTER);            
  text(message,0,0); 
  theta += 0.01;                 
  
  delay(5);       
}

Explanation

CODE 2

Function Analyse

This code is a function that makes the messages rotate on its own.

PFont f;
String message = "Yann";
float theta, deg;

As you can see, the first part of the code is the part where the users can define the message that they want. It is also the part where the user declares the variable. The phrase "Yann" is define through the string function. The phrase "Yann" is named as message and is referred as message throughout the whole code. It will make the user easier to change the phrase. If the user wanted to change the phrase, the only thing that they need to change is the phrase inside the quotation mark which is the "Yann" in this cod

void setup() {
  size(600, 600);
  // fullScreen();
  f = createFont("SentyWen",60,true);
}

In the second part of the code, it is used to declare the setup of the code. User can define things such as screen size and font. The void setup() is extremely important as it's used to define initial environment properties such as screen size and to load media such as images and fonts as the program starts. There can only be one setup() function for each program and it shouldn't be called again after its initial execution.

void draw() { 
  background(213,345,333);
  fill(0);
  textFont(f);     
  translate(width/2,height/2);   
  rotate(theta);                   
  // rotate(radians(deg)); 
  textAlign(CENTER);            
  text(message,0,0); 
  theta += 0.01;                 
  delay(5);       
}

Finally is the last part of the code. Without this part, the whole function will not work. This is where the user set it to make the whole message rotate. As shown above, it is shown that the phrase first translates to the centre of the screen *translate(width/2,height/2);*, then the rotate(theta);   will allow the user to make the phrase rotate around theta. In addition, users can also decide the background and the found colour in the last part of the code.

Original Code

PFont f;
String message = "My word";
float theta, deg;
 
void setup() {
  size(600, 400);
  // fullScreen();
  f = createFont("Arial",20,true);
}
 
void draw() { 
  background(255);
  fill(0);
  textFont(f);                     // Set the font
  translate(width/2,height/2);   // Translate to the center
  rotate(theta);                   // Rotate by theta in radians
  // rotate(radians(deg));   // Rotate by degrees using the radians function
  textAlign(CENTER);            
  text(message,0,0); 
  theta += 0.01;                  // Increase rotation by radians
         // Increase rotation by degrees
  // deg += 1;
  delay(50);       // Control rotational speed via milliseconds delay
}

Orignal Code

Modifications

  • The string messages was changed from "My word" to "Yann"

  • The screen size was changed from "size(600,400)" to "size(600,600)".

  • The background colour was changed

  • The speed of the phrase rotating hes increased.

bottom of page