hello processing geniuses,
im working on a logo that involves a harmonious group of particles that revolves around a letterform; i need some help with the particles. so heres the gist of it: each particle is generated by a tweet that consist of six different keywords: air and space, creative court, ecosystems, innovation lab, rain forest, and world of life. each keyword is represented by different colored particles, as shown below:
air and space tweet : dark purple particle
creative court tweet: orange particle
eco systems tweet
: blue
particle
innovation lab tweet
: pink
particle
rain forest tweet
: green
particle
world of life tweet
: red
particle
the differentiation of the colors, once the particles are generated by twitter feeds, allow the user to see just about which topic is most popular; if
green particles seem to populate the space more so than other colors, they get a clearer sense that the topic of
rain forests is most talked about.
heres my question: for my set of codes, i was wondering if you guys can help me write how i can make this function possible.
also, i was wondering if you guys can help me how to tie in the twitter feed function to my code.
for now, the particles can be generated by clicking the screen.
for the processing code,
i have set two tabs to reduce the clustering of codes.
if you prefer the actual code, you can download it here:
http://www.mediafire.com/?zqach4y6p6vb4qj
note: the gradient function is very important, so the twitter function is powered by twitter4j.
thanks! much appreciated
TAB ONE CODES:
ArrayList particles;PShape a;Twitter twitter;Query q;/*Mover[] movers = new Mover[190];Mover[] movers2 = new Mover[25];Mover[] movers3 = new Mover[7];*/color col;String[] terms = {"airandspace", "creativecourt", "ecosystems", "innovationlab", "rainforest" , "worldoflife"};int[] hues = {30, 25, 80, 60, 80};int index = 0;
//VOID SETUP////////////////////void setup() {size(800, 800);smooth();background(0);color(HSB, 100);frameRate(70);
//twitter stuffConfigurationBuilder cb = new ConfigurationBuilder();cb.setOAuthConsumerKey("PLmGEQtruhjtEDryFyx0rA");cb.setOAuthConsumerSecret("yN5ubhMXKkJjRF151m2M2awWQXmkaQzMgOkksyLtI");cb.setOAuthAccessToken("317405665-ojRo56DtA5KFvfujk39EM60g9Tk75DrE0f4VvO2N");cb.setOAuthAccessTokenSecret("oo2LazqjdMzYtiFUTlQWA3vzmifTOxUA3C8xzB11E");
twitter = new TwitterFactory(cb.build()).getInstance();
/*try{QueryResult result = twitter.search(q);ArrayList tweets = (ArrayList) result.getTweets();Tweet t = (Tweet) tweets.get(0);particles = new ArrayList();particles.add(new Mover(4, .07));println(t.getText());}catch(TwitterException te){}*/
particles = new ArrayList();col = color(hues[index], random(80, 100), random(60, 90));particles.add(new Mover(col, 4, .07));//Mover p = (Mover)particles.get(0);//println(p.msg);
a = loadShape("mos.svg");/*for (int i = 0; i < movers.length; i++) {movers[i] = new Mover(4, .07);}for (int i = 0; i < movers2.length; i++) {movers2[i] = new Mover(4, .13);}for (int i = 0; i < movers3.length; i++) {movers3[i] = new Mover(4, .2);}*/}
void draw(){noStroke();fill(255);rect(0, 0, width, height);
// create a timer to call createParticles();
for (int i=0; i<particles.size(); i++){Mover m = (Mover) particles.get(i);m.checkEdges();m.update();m.display();
if (m.finished()) {// Items can be deleted with remove()particles.remove(i);}}}
void mousePressed() {createParticles();}
void createParticles(){index = int(random(terms.length));col = color(hues[index], random(80, 90), random(90, 100));particles.add(new Mover(col, 4, .07));}
/*//VOID DRAW////////////////////void draw() {noStroke();fill(255);rect(0, 0, width, height);/*for (int i = 0; i < movers.length; i++) {movers[i].update();movers[i].checkEdges();if (!finished) movers[i].display();movers[i].fadeOut();}for (int i = 0; i < movers2.length; i++) {movers2[i].update();movers2[i].checkEdges();if (!finished) movers2[i].display();movers2[i].fadeOut();}for (int i = 0; i < movers3.length; i++) {movers3[i].update();movers3[i].checkEdges();if (!finished) movers3[i].display();movers3[i].fadeOut();}*///shape (a, -200, -200, 1200, 1200);//}
TAB TWO CODES:
class Mover {
PVector location;PVector velocity;PVector acceleration;//fade out funtion; the larger the number, the longer////////////////////float life = 3550;float topspeed;int size;float multiplier;color col;String msg;
Mover(color tcol, int xsp, float xmu) {size = int(random(4, 1));location = new PVector(random(width), random(height));velocity = new PVector(random(width), random(height));topspeed = xsp;multiplier = xmu;msg = getMsg();int x = int(random(0, 255));
float c = random(0, 80);float m = random(0, 55);float y = random(0, 0);float k = random(0, 30);//col = convert(c, m, y, k);col = tcol;}
//fade out funtion////////////////////boolean finished() {// Balls fade outlife-=10;if (life < 0) {return true;}else {return false;}}
void fadeOut() {// Balls fade outlife--;}
//VOID UPDATE////////////////////void update() {PVector mouse = new PVector(width/2, height/2);PVector dir = PVector.sub(mouse, location);dir.normalize();dir.mult(multiplier);acceleration = dir;
velocity.add(acceleration);velocity.limit(topspeed);location.add(velocity);}
//COLOR//9*I;//////////////////color convert(float c, float m, float y, float k) {c = c / 100;m = m / 100;y = y / 100;k = k / 100;
c = ( c * ( 1 - k ) + k );m = ( m * ( 1 - k ) + k );y = ( y * ( 1 - k ) + k );
float r = ( 1 - c ) * 255;float g = ( 1 - m ) * 255;float b = ( 1 - y ) * 255;
return color(r, g, b);}
//VOID DISPLAY////////////////////void display() {noStroke();fill(col, life/10.0);ellipse(location.x, location.y, size, size);}
void checkEdges() {
if (location.x > width) {location.x = 0;}else if (location.x < 0) {location.x = width;}
if (location.y > height) {location.y = 0;}else if (location.y < 0) {location.y = height;}}
String getMsg(){try {q = new Query(terms[index]);q.setRpp(1);
QueryResult result = twitter.search(q);//Cast the list of tweets into an ArrayListArrayList tweets = (ArrayList) result.getTweets();
//and instead of a for loop, just get(0);//Pull out this particular Tweet object.Tweet t = (Tweet) tweets.get(0);return t.getText();
//println(usr+ ": " + msg + " ("+d+")");}catch(TwitterException te) {//println(te);return te.toString();}}}
1