We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Little applet for social networks' links
Page Index Toggle Pages: 1
Little applet for social networks' links (Read 564 times)
Little applet for social networks' links
Oct 16th, 2009, 6:43pm
 
  Hello! Just sketched little applet for social network visualizing. It is not finished yet - sorry for hard-coding in advance... You need some font to run it.
Code:

circle circleYa,circleGoo;
circle a1,a2,a3,a4,a5,a6,a7,a8,a9,z1,z2,z3,z4,z5,z6;
circle circleYar,circleGoor,a2r;

PFont fontA;
void setup() {
 size(1000,100);

 //background(336699);
 circleYa = new circle(812,10,33,25,14,812,10,812,10,28,"Yahoo.com",812,10);
 circleGoo = new circle(620,33,33,25,14,620,25,735,90,28,"Google.com",620,33);

 a4 = new circle(802,75,19,15,8,circleYa.x,circleYa.y,802,75,24,"",802,75);
 a5 = new circle(860,90,19,15,8,circleYa.x,circleYa.y,860,90,24,"",860,90);
 a6 = new circle(880,35,19,15,8,circleYa.x,circleYa.y,880,35,24,"facebook.com",880,35);
 a7 = new circle(955,98,19,15,8,circleYa.x,circleYa.y,955,98,24,"",955,98);
 a8 = new circle(985,40,19,15,8,circleYa.x,circleYa.y,985,40,24,"",985,40);
 a9 = new circle(940,10,19,15,8,circleYa.x,circleYa.y,940,10,24,"",940,10);
 z1 = new circle(700,15,19,15,8,circleGoo.x,circleGoo.y,700,15,24,"",700,15);
 z2 = new circle(495,30,19,15,8,circleGoo.x,circleGoo.y,495,30,24,"myspace.com",495,30);

 z4 = new circle(445,65,19,15,8,circleGoo.x,circleGoo.y,445,65,24,"bebo.com",445,65);
 z5 = new circle(560,90,19,15,8,circleGoo.x,circleGoo.y,560,90,24,"",560,90);
 z6 = new circle(570,0,19,15,8,circleGoo.x,circleGoo.y,570,5,24,"friendster.com",570,0);

 a1 = new circle(700,15,19,15,8,circleYa.x,circleYa.y,z1.x,z1.y,24,"",700,15);
 a3 = new circle(755,40,19,15,8,circleYa.x,circleYa.y,z1.x,z1.y,24,"hi5.com",755,40);
 a2 = new circle(735,90,19,15,8,circleYa.x,circleYa.y,z1.x,z1.y,24,"",735,90);
 z3 = new circle(640,65,19,15,8,circleGoo.x,circleGoo.y,a2.x,a2.y,24,"",640,65);

 // Covering lines by 1 more layer (duplicating drawing)
 circleYar = new circle(circleYa.x,circleYa.y,33,25,14,circleYa.x,circleYa.y,circleYa.x,circleYa.y,18,"",circleYa.x,circleYa.y);
 circleGoor = new circle(circleGoo.x,circleGoo.y,33,25,14,circleGoo.x,circleGoo.y,circleGoo.x,circleGoo.y,18,"",circleGoo.x,circleGoo.y);
 a2r = new circle(a2.x,a2.y,19,15,8,a2.x,a2.y,a2.x,a2.y,18,"",a2.x,a2.y);

 fontA = loadFont("2.vlw");

}

void draw() {

 smooth();
 noStroke();
 background(40,80,150);
 circleYa.show();
 circleGoo.show();
 a1.show();
 a2.show();
 a3.show();
 a4.show();
 a5.show();
 a6.show();
 a7.show();
 a8.show();
 a9.show();
 z1.show();
 z2.show();
 z3.show();
 z4.show();
 z5.show();
 z6.show();
 circleYar.show();
 circleGoor.show();
 a2r.show();
 //??????????
 textFont(fontA, 24);
 text("built with Processing",5,95);
}

class circle{
 int x;
 int y;
 int xx,yy,xxx,yyy;
 int r1,r2,r3;
 int fontsize;
 String tex;
 int aa;
 int ss;
 boolean dsa = false;
 int distax, distay;
 circle(int x,int y, int r1,int r2,int r3,int xx, int yy,int xxx, int yyy, int fontsize, String tex,int aa,int ss){
   this.x=x;
   this.y=y;
   this.r1=r1;
   this.r2=r2;
   this.r3=r3;
   this.xx=xx;
   this.yy=yy;
   this.xxx=xxx;
   this.yyy=yyy;
   this.fontsize=fontsize;
   this.tex=tex;
   this.aa=aa;
   this.ss=ss;

 }

 void follow(){

   if ((mouseX > x-r1 )&&(mouseX < x+r1) && (mouseY < y+r1) && (mouseY > y-r1)) {
     x = mouseX;
     y = mouseY;
     distax = abs(aa-mouseX);
     distay = abs(ss-mouseY);
     if(distax>r1 || distay>r1){
       x=aa;
       y=ss;
     }
   }


 }
 void show(){


   smooth();
   fill(255);
   textFont(fontA, fontsize);
   text(tex,x+20,y+15);
   follow();  

   stroke(190);
   line(x,y,xx,yy);
   line(x,y,xxx,yyy);
   noStroke();
   translate(0, 0);
   fill(190);
   ellipse(x,y,r1,r1);
   fill(50,50,250);
   ellipse(x,y,r2,r2);
   fill(255,80);
   ellipse(x,y,r2,r2);
   fill(255);
   ellipse(x,y,r3,r3);


 }
 void mousePressed(){
   if ((mouseX > x-r1 )&&(mouseX < x+r1) && (mouseY < y+r1) && (mouseY > y-r1)) {
     link("http://"+tex);

   }
 }
}
void mousePressed(){
 circleYa.mousePressed();
 circleGoo.mousePressed();
 a1.mousePressed();
 a2.mousePressed();
 a3.mousePressed();
 a4.mousePressed();
 a5.mousePressed();
 a6.mousePressed();
 a7.mousePressed();
 a8.mousePressed();
 a9.mousePressed();
 z1.mousePressed();
 z2.mousePressed();
 z3.mousePressed();
 z4.mousePressed();
 z5.mousePressed();
 z6.mousePressed();

}

Page Index Toggle Pages: 1