FB social graph


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import processing.opengl.*;
  2.  
  3. void setup() {
  4.  
  5. size(1100, 1100, OPENGL);
  6.  
  7. background(0,30,60);
  8.  
  9. PFont font;
  10. font = loadFont("SansSerif-48.vlw");
  11. textFont(font);
  12. fill(255);
  13.  
  14. translate(width/2, height/2);
  15. textAlign(RIGHT);
  16. textSize(10);
  17.  
  18. String friends[] = loadStrings("friends"); //friend names sorted by id
  19. String connections[] = loadStrings("connections"); //comma separated friend ids
  20.  
  21. float r = 420;
  22. stroke(255, 30);
  23.  
  24. for (int j=0; j<connections.length; j++) {
  25. int[] node = int(split(connections[j], ','));
  26. line(r*cos(PI + 2*PI/friends.length*(node[0]+0.5)), r*sin(PI + 2*PI/friends.length*(node[0]+0.5)),
  27. r*cos(PI + 2*PI/friends.length*(node[1]+0.5)), r*sin(PI + 2*PI/friends.length*(node[1]+0.5))
  28. );
  29. }
  30.  
  31. for (int i=0; i<friends.length; i++) {
  32. //println(friends[i]);
  33. text(friends[i], -r-2, 0);
  34. rotate(2*PI/friends.length);
  35. }
  36. }
  37.  
  38. void draw() {
  39. //nothing yet
  40. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.