Week 7: Wor­k­i­n­g with Fonts

by Gawshika Aumkaran

Displaying Text - Within a Small Rectangle

  • Show Sketch
/** @peep sketchcode */
size(300, 300);
background(204);
fill(0); 
textSize(35);
String s = "Working with Fonts"; 
text(s, 100, 120, 80, 50);

Creating a Dropshadow

  • Show Sketch
/** @peep sketchcode */
size(200, 200);
background(204);
String s = "Creating a Dropshadow"; 
textSize(20);
fill(0, 70);
text(s, 60, 73, 100, 50);
textSize(19);
fill(0, 64);
text(s, 60, 71, 100, 50);
textSize(18);
fill(255);
text(s, 60, 69, 100, 50);

Animating Text [with own font]

  • Show Sketch
/** @peep sketchcode */
/* @pjs font=/uploads/16114/quicksand-regular.otf; */
 
String scrollingText = "Quicksand is the font that I've chosen to show you how easy it is to animate text in Processing.";
 
float x;
float dx = -1;
 
void setup() {
  size(200, 200);
  PFont font = createFont("/uploads/16114/quicksand-regular.otf", 72);
  textFont(font);
  x = width;
}
 
void draw() {
  background(204);
  fill(0);
  textAlign(LEFT, CENTER);
  text(scrollingText, x, height/2 + 20);
  x += dx;
  if (x <= -textWidth(scrollingText)) x = 200;
}

Comments

Nobody has said anything yet.