# Node Garden

**URL:** <https://forum.kirupa.com/t/node-garden/213493>\
**Category:** open source\
**Created:** [January 20, 2007, 12:11am UTC](https://forum.kirupa.com/t/node-garden/213493 "2007-01-20T00:11:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sammo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sammo/32/779_2.png) [@Sammo](https://forum.kirupa.com/u/Sammo)\
**Post date:** [January 20, 2007, 12:11am UTC](https://forum.kirupa.com/t/node-garden/213493/1 "2007-01-20T00:11:08Z")

</div>

Nothing new, but it’s good for practice 🙂

```auto
import flash.geom.Point;

Math2 = {
	random: function(start, end) {
		return start + Math.floor(Math.random() * end);
	}
}
num = 40;
nodes = [];
for (i = 0; i < num; i++) {
	nodes* = new Point(Math2.random(1, Stage.width), Math2.random(1, Stage.height));
	nodes*.velocity = {x: Math2.random(-5, 10), y: Math2.random(-5, 10)};
}

function onMouseDown() {
	for (i = 0; i < nodes.length; i++) 
		nodes*.velocity = {x: Math2.random(-5, 10), y: Math2.random(-5, 10)};
}

function onEnterFrame() {
	for (i = 0; i < nodes.length; i++) {
		nodes*.x += nodes*.velocity.x;
		nodes*.y += nodes*.velocity.y;
		if (nodes*.x > Stage.width || nodes*.x < 0) nodes*.velocity.x *= -1;
		if (nodes*.y > Stage.height || nodes*.y < 0) nodes*.velocity.y *= -1;
	}
	clear();
	for (i = 0; i < nodes.length - 1; i++) {
		for (j = i + 1; j < nodes.length; j++) {
			distance = Point.distance(nodes*, nodes[j]);
			if (distance < 120) {
				alpha = 100 - distance / 120 * 100;
				lineStyle(1, 0x000000, alpha);
				moveTo(nodes*.x, nodes*.y);
				lineTo(nodes[j].x, nodes[j].y);
			}
		}
	}
}

```

Example: [http://img136.imageshack.us/my.php?image=pointnetkf3.swf](http://img136.imageshack.us/my.php?image=pointnetkf3.swf)
