import processing.core.*; 
import processing.xml.*; 

import java.applet.*; 
import java.awt.*; 
import java.awt.image.*; 
import java.awt.event.*; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class side_scrolling_text extends PApplet {

/**
 * Letters. 
 * 
 * Draws letters to the screen. This requires loading a font, 
 * setting the font, and then drawing the letters.
 */

PFont fontA;

int offset=0;
int i=0;
int NUMCHARS=4;
int letter_width=250;
String msg="THIS IS THE BANNER MESSAGE";

public void setup() 
{
  size(800, 600);
  background(255);
  smooth();
  // Load the font. Fonts must be placed within the data 
  // directory of your sketch. A font must first be created
  // using the 'Create Font...' option in the Tools menu.
  // Uncomment the following two lines to see the available fonts 
  //String[] fontList = PFont.list();
  //println(fontList);

  textAlign(LEFT);
  fontA = createFont("Helvetica-Bold", 255);
  fill(0);
  textFont(fontA, 600);
  
  //textMode(SCREEN);
  i=0;
  offset=PApplet.parseInt(textWidth(msg.charAt(i)));
} 

public void draw()
{
  
  background(255);
  fill(0);
   
  text(msg.substring(i, i+NUMCHARS), 0, 500);

  offset-=1;
  if(offset<=0) {
    offset=PApplet.parseInt(textWidth(msg.charAt(i)));
    i+=1;
  };
  
  if(i>msg.length()-NUMCHARS) {
    exit();
  }
}

  static public void main(String args[]) {
    PApplet.main(new String[] { "--bgcolor=#c0c0c0", "side_scrolling_text" });
  }
}
