0

I have a project, in processing, where I want to scrape twitter tweets, then create a flock of boids based on the words of the tweets. Using the flocking example here as base: https://processing.org/examples/flocking.html, I have about 95% of the project done.

The problem now is I want to alter the flocking code so that instead of 1 generic shape (in the example code it was triangles) I want to use the text() function to draw the words of the tweets. Well currently when I do that I get the words stacked on top of each other. Here is the code I'm using:

void render() {
float theta = velocity.heading() + radians(0);
fill(255, 255, 255);
stroke(255);
pushMatrix();
translate(location.x, location.y);
for (int i = 0; i < words1.length; i++) {
rotate(theta);
text(words1[i], 0, 0);
}
popMatrix();

}

From my testing the appears the problem is in the translate portion of the code. location.x and location.y are the current location of the boids this works fine for a single shape, but if I have to track multiple different shapes this might be a problem. Any ideas how to do this without having to rewrite the boids code to run separately for each word of the tweet?

Travis
  • 19
  • 4
  • What is this code supposed to do, exactly? Why are you rotating and drawing a bunch of words? What is the result of this? Can you post a screenshot? Can you provide an [MCVE](http://stackoverflow.com/help/mcve)? – Kevin Workman Oct 21 '14 at 13:39
  • Travis, it looks like currently you have a String[] in each Boid instance, but it sounds like you want a single word per Boid. When you retrieve your String[], loop through the words and create a new Boid per word (and have the Boid code us a single String instead of a String[]). This will resolve the one word per boid issue (however your words will probably start grouped, depending on how you initialize your boid positions, but might stay grouped s you continue the simulation). Make sure you set different separations for each boid instance based on the word dimensions (see `textWidth()`) – George Profenza Oct 21 '14 at 20:33
  • SUPER LATE reply. But I am an idiot and figured this out. If possible this question can be deleted. – Travis Jan 27 '15 at 19:39

0 Answers0