Member 208
6 entries
25061 views

Project moderator:

 C.E.B. Reas (M)Los Angeles, US Immortal since Dec 8, 2007 Uplinks: 0, Generation 1 REAS
Recently commented on
 From rhymeandreason"draw tangent to..." part...
reas’ project
Emergence and Navigating...
Develop a generative, emergent process to fill space (2D or 3D) using only black lines. Modify a known process or invent your own. Implement your...
Now playing SpaceCollective
Where forward thinking terrestrials share ideas and information about the state of the species, their planet and the universe, living the lives of science fiction. Introduction
Featuring Powers of Ten by Charles and Ray Eames, based on an idea by Kees Boeke.
// This is general, simple code for each element to be "aware"
// of every other element. Specifically, it draws a line from each
// node to every other node.

Node[] nodes;

void setup() {
size(600, 600);
nodes = new Node[6];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new Node(random(width), random(height), 10, nodes, i);
}
}

void draw() {
for (int i=0; i < nodes.length; i++) {
nodes[i].connect();
nodes[i].display();
}
}

class Node {
float x;
float y;
float diameter;
Node[] otherNodes;
int id;

Node (float xin, float yin, float din, Node[] others, int idin) {
x = xin;
y = yin;
diameter = din;
otherNodes = others;
id = idin;
}

void connect() {
for (int i=id; i < nodes.length; i++) {
line(x, y, otherNodes[i].x, otherNodes[i].y);
}
}

void display() {
ellipse(x, y, diameter, diameter);
}

}
Thu, Jan 17, 2008  Permanent link
Categories: code
Sent to project: Emergence and Navigating Space