scrolling text
in
Contributed Library Questions
•
2 years ago
hello im trying to scroll some streaming twitter text (sketch using twitter4j lib)
can anyone help me do this?
shall i use a text area / screen text library? i know this is really simple but im running out of time on a tight deadline, so if anyone could show me what to do id be really happy.
thanks.
- import com.twitter.processing.*;
- import java.awt.TextArea;
- TextArea screen_text;
- // this stores how many tweets we've gotten
- int tweets = 0;
- // and this stores the text of the last tweet
- String tweetText = "sad";
- char sa2[] = {'t', 't' };
- void setup() {
- size(1440,900);
- // set up fonts
- PFont font = loadFont("CharcoalCY-24.vlw");
- textFont(font, 20);
- // set up twitter stream object
- TweetStream s = new TweetStream(this, "stream.twitter.com", 80, "1/statuses/filter.json?track=sad", "username", "password");
- s.go();
- }
- void draw() {
- background(0);
- fill(36,92,255);
- // draw a box as many pixels wide as the number of tweets we've seen
- rect(20, 20, tweets, 40);
- // and draw the text of the last tweet
- //String[] sa1 = { "OH ", "NY ", "CA "};
- //String[] sa2 = append(sa2, tweetText);
- //println(sa2); // Prints OH, NY, CA, MA
- text(tweetText, 20, 100);
- }
- // called by twitter stream whenever a new tweet comes in
- void tweet(Status tweet) {
- // print a message to the console just for giggles if you like
- println(" " + tweet.text());
- // store the latest tweet text
- tweetText = tweet.text();
- // bump our tweet count by one bar
- tweets += 100;
- if (tweets >1400){
- tweets = 0;
- }
}
1