push universe / create processing
components.push(new Universe());
// setup processing object
p.setup = function() {
p.size(width, height);
p.noStroke();
p.frameRate( 60 );
p.fill(0, 0, 0);
startedAt = new Date();
}
p.mouseMoved = function(){
mx = p.mouseX;
my = p.mouseY;
}
p.mousePressed = function() {
var d = new Date().getTime() - startedAt.getTime();
/* events.push(d);
console.log(events); */
if(focusedParticleIndex != null) {
pixels[focusedParticleIndex].flightMode = 0;
pixels[focusedParticleIndex].toSize = Math.random()*10+1;
}
for(var i = 0; i<numParticles; i++ ) {
if(pixels[i].flightMode == 1) {
pixels[i].flightMode = 2;
pixels[i].toSize = 100;
pixels[i].toX = 200;
pixels[i].toY = height/2;
focusedParticleIndex = i;
var randomTweet = theTweets[Math.floor(Math.random()*theTweets.length)];
var text = randomTweet.text.replace(/http:\/\/(\S+)/, "<a href=\"http://$1\">http://$1>");
text = text.replace(/@(\S+)/, "<a href=\"http://twitter.com/$1\">@$1</a>");
//alert(text);
//var text = "creative technology";
//var el = jQuery('<li><div class="content bubble_' + counter + '"><p>' + text + '</p></div><div class="user"><img src="' + data.results[i].profile_image_url + '" width="48" height="48" /> <a href="http://twitter.com/' + data.results[i].from_user + '">' + data.results[i].from_user + '</a></div></li>');
//jQuery('#tweets').append(el);
//counter++;
$('#tweet').html('<h1>' + text + '</h1><strong><a href="http://twitter.com/' + randomTweet.from_user + '"><img src="' + randomTweet.profile_image_url + '" width="20" height="20" border="0" /> ' + randomTweet.from_user + '</a></strong>');
$('#tweet').show();
$('a').css('color', 'rgb(' + Math.floor(pixels[i].r) + ',' + Math.floor(pixels[i].g) + ',' + Math.floor(pixels[i].b) + ')');
// abort for loop
i = numParticles;
}
}
}
p.draw=function(){
if(play) {
for (var i=0; i<components.length; i++) {
components[i].update();
}
p.background( 0 );
for (var i=0; i<components.length; i++) {
components[i].draw();
}
}
}
// browser detection
if (.browser.mozilla == true) {
$('#audio').attr('src', 'thankyou.ogg');
} else {
$('#audio').attr('src', 'thankyou.mp3');
}
$('#tweet').css('top', Math.floor(height/2-52) + 'px');
p.init();
$('#tweet').attr('unselectable', 'on');
$('#tweet').css('MozUserSelect', 'none');
$('#tweet').css('KhtmlUserSelect', 'none');