tut­o­r­i­a­l 12 - fonts

by Lisa Deng
  • Show Sketch
/** @peep sketchcode */
 
String firstName = "Lisa";
String lastName = "Deng";
String fullName= firstName + " " + lastName;
println(fullName);
 
size (100,100);
background (230);
fill(0);
//draw text in display window
text ("Hello", 10,10);
textSize(10);
text (fullName,40,10);
textSize(10);
fill(0,60);
text ("Welcome to Processing", 10,31,90,71);
fill(244,0,0);
text ("Welcome to Processing", 10,30,90,70);

Comments

    Lisa Deng about a year ago
    • Show Sketch
    /* @pjs font=/media/css/Chunkfive-webfont.ttf; */
    /** @peep sketchcode */
    size(100, 100);
    background(204);
    PFont font = createFont("/media/css/Chunkfive-webfont.ttf", 32);
    textFont(font);
    fill(128, 0, 0,30); // Red 
    text("RED", 0, 40); 
    fill(0, 128, 0,100); // Green 
    text("GRN", 0, 70); 
    fill(128, 128, 0,40); // Green 
    text("GRN", 0, 72); 
    fill(0, 0, 128,70); // Blue 
    text("BLU", 0, 100);
    Lisa Deng about a year ago
    • Show Sketch
    /* @pjs font=/media/css/Chunkfive-webfont.ttf; */
    /** @peep sketchcode */
     
    String scrollingText = "This is a long sentence that I've just written to show you how easy it is to animate text in Processing.";
     
    float x;
    float dx = -1;
    float x2;
    float dx2 = 1;
     
    void setup() {
      size(200, 200);
      PFont font = createFont("/media/css/Chunkfive-webfont.ttf", 72);
      textFont(font);
      x = width;
      x2= -15*width; 
    }
     
    void draw() {
      background(204);
      fill(0);
      textAlign(LEFT, CENTER);
      text(scrollingText, x, height/4 + 20);
      //line1 text
      x += dx;
      if (x <= -textWidth(scrollingText)) x = 200;
        text(scrollingText, x, height/4 + 20);
      //line2 text
      x2 += dx2;
      if (x2 <= -textWidth(scrollingText)) x2 = -1000;
        text(scrollingText, x2, height/4*3 + 20);
    }