Last active
December 24, 2015 21:49
-
-
Save nguyenj/6868169 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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