Skip to content

Instantly share code, notes, and snippets.

@nguyenj
Last active December 24, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nguyenj/6868169 to your computer and use it in GitHub Desktop.
Save nguyenj/6868169 to your computer and use it in GitHub Desktop.
// TODOs
// - boolean for node overlay
// -- if overlay redraw node
Node[] node = new Node[25];
void setup() {
size(400, 400);
background(255);
smooth();
noStroke();
// Display nodes
for ( int i = 0; i < node.length; i++ ) {
float r = random(10, 50);
float x = random(r, width - r);
float y = random(r, height -r);
node[i] = new Node(x, y, r);
node[i].display();
}
// Connect nodes
for ( int i = 0; i < node.length; i++ ) {
stroke(50, 187, 237, 25);
for ( int j = 0; j < node.length; j++ ) {
if ( i != j ) {
line(node[i].x, node[i].y, node[j].x, node[j].y);
}
}
}
}
class Node {
float x, y, r;
Node( float temp_x, float temp_y, float temp_r ) {
x = temp_x;
y = temp_y;
r = temp_r;
}
void display() {
noStroke();
fill(50, 187, 237, 75);
ellipse(x, y, r+10, r+10);
fill(50, 187, 237);
ellipse(x, y, r, r);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment