top of page

CODE 9

PFont f;
  
void setup() {
  size(640, 720);
  
  // Create the font
  printArray(PFont.list());
  f = createFont("SentyWen", 24);
  textFont(f);
}

void draw() {
  background(117,137,191);
  textAlign(RIGHT);
  drawType(width * 0.25);
  textAlign(CENTER);
  drawType(width * 0.5);
  textAlign(LEFT);
  drawType(width * 0.75);
}
void drawType(float x) {
  line(x, 0, x, 65);
  line(x, 220, x, height);
  fill(207, 236, 207);
  text("Khoo", x, 95);
  fill(181, 225, 174);
  text("Yan", x, 130);
  fill(145, 210, 144);
  text("Xuan", x, 165);
  fill(255);
  text(":)", x, 210);
}

CODE 9

Screenshot 2020-05-28 at 17.12.24.png
Function Analyse

This code align text and lines on a screen as you can see, it is shown above. As shown above, there are three lines of text having the same information. One line is aligned to the left, another one is aligned to the center and the last line is align to the right. This allows it to see neat and more aesthetic.

textAlign(RIGHT);
  drawType(width * 0.25);
  textAlign(CENTER);
  drawType(width * 0.5);
  textAlign(LEFT);
  drawType(width * 0.75);

The text can be change by changing the phrase inside the function text() and the colour can also change by changing the RGB values inside the function fill().

fill(207, 236, 207);
  text("Khoo", x, 95);
  fill(181, 225, 174);
  text("Yan", x, 130);
  fill(145, 210, 144);
  text("Xuan", x, 165);
  fill(255);
  text(":)", x, 210);

Original Code
Original Code
Screenshot 2020-05-29 at 11.38.52.png
Modifications

1) Size of the screen:

size(640, 720);

to

size(640, 360);

6) Background Colour:

background(102);

to

background(117,137,191);

6) Text and Colour of the text:

fill(0);
  text("ichi", x, 95);
  fill(51);
  text("ni", x, 130);
  fill(204);
  text("san", x, 165);
  fill(255);
  text("shi", x, 210);

to

fill(207, 236, 207);
  text("Khoo", x, 95);
  fill(181, 225, 174);
  text("Yan", x, 130);
  fill(145, 210, 144);
  text("Xuan", x, 165);
  fill(255);
  text(":)", x, 210);

PFont f;
  
void setup() {
  size(640, 360);
  
  // Create the font
  printArray(PFont.list());
  f = createFont("SentyWen", 24);
  textFont(f);
}

void draw() {
  background(102);
  textAlign(RIGHT);
  drawType(width * 0.25);
  textAlign(CENTER);
  drawType(width * 0.5);
  textAlign(LEFT);
  drawType(width * 0.75);
}
void drawType(float x) {
  line(x, 0, x, 65);
  line(x, 220, x, height);
  fill(0);
  text("ichi", x, 95);
  fill(51);
  text("ni", x, 130);
  fill(204);
  text("san", x, 165);
  fill(255);
  text("shi", x, 210);
}

 

bottom of page