Google Community Chat
 
Google Particle Logo

You're visiting Google Community as a guest.
In order to post, you'll need to register and log in.


(If you were registered and logged in, these advertisements wouldn't be here)
Post new topic   Reply to topic    Google Community Forum Index // Other Google Features
   
Author Message
geekerati
Google elgooG
Platinum Member


Joined: 17 Jan 2005
Location: Deep in the heart.
21217.12 GC$

Items

PostPosted: Sun Jan 08, 2006 1:18 am    Post subject: Google Particle Logo Reply with quote
This is soo cool! Fire up the java and enjoy. Smile
Google Particle Logo

Load the code!
Quote:

int dot_total = 5000;
dot [] dot_array = new dot [dot_total];

BImage bg;
int bgW, bgH, bgSx, bgSy;
int black_array [][] = new int [400*200][3];

void setup(){
size(600,400);
background(255);
bg_setting();
bg_array_setting();
init_dot();
}
void bg_setting(){
bg = loadImage("http://www.google.com/images/logo.gif");
bgW = bg.width;
bgH = bg.height;
bgSx = (width-bgW)/2;
bgSy = (height-bgH)/2;
}
int k = 0;
void bg_array_setting(){
for(int i=0;i<bgW*bgH; i++){
if(bg.pixels[i] != color(255,255,255)){
black_array[k][0] = i%bgW + bgSx;
black_array[k][1] = int(i/bgW) + bgSy;
black_array[k][2] = bg.pixels[i];
k++;
}
}
}

void init_dot(){
for(int i=0; i<dot_total; i++){
int rand = (int)random(k);
dot_array[i] = new dot();
dot_array[i].ox = black_array[rand][0];
dot_array[i].oy = black_array[rand][1];

dot_array[i].tx = dot_array[i].ox;
dot_array[i].ty = dot_array[i].oy;
dot_array[i].x = dot_array[i].ox;
dot_array[i].y = dot_array[i].oy;

dot_array[i].col = black_array[rand][2];
}
}

void loop(){
background(255);
for(int i=0;i<dot_total; i++){
dot_array[i].move();
}
}

class dot{
float ox,oy,tx,ty,x,y;
float dx,dy,dist;
float mdx,mdy,mdist;
float mx,my;
float damperX,damperY;
color col;
dot(){
damperX = 5 + random(15);
damperY = 5 + random(15);
col = color(0,0,0);
}
void move(){
//calculate distance from mouse cursor
mdx = mouseX - x;
mdy = mouseY - y;
mdist = sqrt(sq(mdx)+sq(mdy));
if(mdist<(20+random(20))){
mx = mouseX - pmouseX;
my = mouseY - pmouseY;
tx = x + mx * (40-mdist)/10 + random(60)-30;
ty = y + my * (40-mdist)/10 + random(60)-30;
damperX = 5 + random(15);
damperY = 5 + random(15);

//change ox,oy randomly
if(random(10)<1){
int rand = (int)random(k);
ox = black_array[rand][0];
oy = black_array[rand][1];
col = black_array[rand][2];
}

}else
if(abs(tx-x)<1+random(10) && abs(ty-y)<1+random(10)){
tx = ox + random(20) - 10;
ty = oy + random(20) - 10;
}

dx = tx-x;
dy = ty-y;
dist = sqrt(sq(dx)+sq(dy));
x += dx/damperX;
y += dy/damperY;

draw_me();
}
void draw_me(){
noStroke();
fill(col);
rect(x,y,1,1);
}
}

_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sponsored Links
Posted: 4 Dec 2008 1:18 am    Post subject: Advertisements
Back to top
Post new topic   Reply to topic    Google Community Forum Index // Other Google Features All times are GMT - 8 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Host your free forums with Invision Plus.net forum web hosting with your own subdomain.

alexisBlue v1.2 // Theme Created By: Andrew Charron // Icons in Part By: Travis Carden

© 2005-2006 Google Community

Powered by phpBB

Privacy Policy | Contact Us

Powered by Google Search blog

This website is not affiliated in any way with Google, Inc.
Google™ is a registered trademark of Google, Inc.