Fading Images In/Out
in
Programming Questions
•
2 years ago
Hey there, I'm having trouble getting my images to fade in and out. I know I need to use tint(); but I'm having more difficulty than I should be. Below is some of my code, hopefully someone can help me figure out what I need to do!
Right now the program is grabbing images from Flickr based on results from a Twitter search, and those images appear one at a time. I need them to fade in and out.
- void draw() {
- background(255);
- if (frameCount % 200 == 1) {
- index++;
- if ( index >= fp.length ) {
- index = 0;
- tweetIndex++;
- if ( tweetIndex >= tweets.length ) tweetIndex = 0;
- String[] tokens = splitTokens(tweets[tweetIndex], " .,;:!@#&*?\"/-()");
- ArrayList stopwords = new ArrayList();
- String[] lines = loadStrings("stopwords.txt");
- String allWords = join(lines, " ").toLowerCase();
- String[] t = splitTokens(allWords, " ");
- for (int i=0; i < t.length; i++) stopwords.add(t[i]);
- ArrayList goodwords = new ArrayList();
- for (int i=0; i < tokens.length; i++) {
- //print(tokens[i]);
- if ( stopwords.contains(tokens[i].toLowerCase()) == false ) {
- // keep that word
- goodwords.add( tokens[i] );
- }
- }
- String[] searchwords = new String[ goodwords.size() ];
- for (int i=0; i < searchwords.length; i++) {
- searchwords[i] = (String)goodwords.get(i);
- }
- fp = new PImage[ searchwords.length ];
- for ( int i=0; i < searchwords.length; i++) {
- PImage[] tmp = flickrSearch( searchwords[i], 1 );
- if ( tmp.length <= 0 ) {
- // use default image
- fp[i] = loadImage("unfocused.jpg");
- }
- else {
- fp[i] = tmp[0];
- }
- }
- }
- }
- image (fp[index], width/2, height/2);
- fill(0);
- text(tweets[tweetIndex], 10, height-10);
- }
1