Animation trail over an image
in
Programming Questions
•
2 years ago
I am very new to Processing. I am trying to visualize tweets over a map and below is what I got so far. Each colored box on the map is a tweet.
I need to visualize the "movement" as well: a person can post a tweet, and then move to different location and post another one, and so on. I would like to show this as an animated trail. The closest I can find is this one. The problem is that the "trail" doesn't work once the map (png file) is added, even I used a buffer as the other posted suggested. Below is the code I used to load the image in draw().
I need to visualize the "movement" as well: a person can post a tweet, and then move to different location and post another one, and so on. I would like to show this as an animated trail. The closest I can find is this one. The problem is that the "trail" doesn't work once the map (png file) is added, even I used a buffer as the other posted suggested. Below is the code I used to load the image in draw().
- PGraphics buffer;
- PImage vastopolis;
- int x=0, y=0;
- void setup() {
- buffer = createGraphics(IMG_WIDTH, IMG_HEIGHT, P2D);
- vastopolis = loadImage(dataPath("Vastopolis_Map.png"));
- }
- public void draw() {
- // for the "trail" effect
fill(0, 0, 0, 10);
rect(0, 0, IMG_WIDTH, IMG_HEIGHT); - // draw the map
buffer.beginDraw();
buffer.image(vastopolis, 0, 0, IMG_WIDTH, IMG_HEIGHT);
buffer.endDraw();
image(buffer, 0, 0); -
- // draw the tweet rectangle
- rect(tweetX+x, tweetY+y, width, height);
-
- // create the "trail" effect
- x++;
- y++;
- }
1