Smily
January 28th, 2006, 07:58 PM
Here's the second version of NodeDraw. You can draw now (as I said in NodeDraw 1) using SHIFT. The little thumbnail on the top left indicates what will be visible and connected. I suggest you don't draw much on it, as every white pixel is treated as a node and will be connected to other white pixels. When you are finished with the drawing, press SPACE and wait for a few seconds/minutes. The time that takes it to process GREATLY depends on the amount of white pixels. Refresh to make a new one and you would probably need to click in it once, to gain focus.
WARNING: This flash file is EXTREMELY cpu heavy. I'm not taking the responsibility of your computer crashing/freezing. It's even more heavy on the cpu than the last one, so please, use with care. :)
ActionScript Code:
var bitmap:flash.display.BitmapData = new flash.display.BitmapData(800, 600, true, 0x000000);
var grid:flash.display.BitmapData = new flash.display.BitmapData(40, 30, false, 0x000000);
var b:MovieClip = _root.createEmptyMovieClip("b", _root.getNextHighestDepth());
var c:MovieClip = _root.createEmptyMovieClip("c", _root.getNextHighestDepth());
var l:MovieClip = c.createEmptyMovieClip("l", c.getNextHighestDepth());
b.attachBitmap(bitmap, b.getNextHighestDepth());
var b:MovieClip = _root.createEmptyMovieClip("t", _root.getNextHighestDepth());
t.attachBitmap(grid, t.getNextHighestDepth());
var iy = 0;
getInt = setInterval(getInfo, 1);
function drawOne() {
for (var ix = 0; ix<grid.width; ix++) {
for (var i = 0; i<grid.width*grid.height; i++) {
var cond = ((grid.getPixel(Math.floor(i%grid.width), Math.floor(i/grid.width)) == 0xFFFFFF) && (grid.getPixel(ix, iy) == 0xFFFFFF)) ? c.l.clear() : 1;
cond = cond == 1 ? 1 : c.l.lineStyle(1, 0xFFFFFF*i/(grid.width*grid.height), 40/Math.sqrt(Math.pow(Math.floor(i%grid.width)-ix, 2)+Math.pow(Math.floor(i/grid.width)-iy, 2)));
cond = cond == 1 ? 1 : c.l.moveTo(Math.floor(i%grid.width)*20, Math.floor(i/grid.width)*20);
cond = cond == 1 ? 1 : c.l.lineTo(ix*20, iy*20);
cond = cond == 1 ? 1 : bitmap.draw(c);
}
}
iy++;
if (iy>grid.height) {
clearInterval(drawInt);
}
}
function getInfo() {
var cond = Key.isDown(Key.SHIFT) ? grid.setPixel(Math.floor(_root._xmouse/20), Math.floor(_root._ymouse/20), 0xFFFFFF) : null;
cond = Key.isDown(Key.SPACE) ? "Run it!" : null;
cond == "Run it!" ? clearInterval(getInt) : "Run it!";
cond == "Run it!" ? drawInt=setInterval(drawOne, 1) : null;
}
Mouse.addListener(ml);
Enjoy ;)
WARNING: This flash file is EXTREMELY cpu heavy. I'm not taking the responsibility of your computer crashing/freezing. It's even more heavy on the cpu than the last one, so please, use with care. :)
ActionScript Code:
var bitmap:flash.display.BitmapData = new flash.display.BitmapData(800, 600, true, 0x000000);
var grid:flash.display.BitmapData = new flash.display.BitmapData(40, 30, false, 0x000000);
var b:MovieClip = _root.createEmptyMovieClip("b", _root.getNextHighestDepth());
var c:MovieClip = _root.createEmptyMovieClip("c", _root.getNextHighestDepth());
var l:MovieClip = c.createEmptyMovieClip("l", c.getNextHighestDepth());
b.attachBitmap(bitmap, b.getNextHighestDepth());
var b:MovieClip = _root.createEmptyMovieClip("t", _root.getNextHighestDepth());
t.attachBitmap(grid, t.getNextHighestDepth());
var iy = 0;
getInt = setInterval(getInfo, 1);
function drawOne() {
for (var ix = 0; ix<grid.width; ix++) {
for (var i = 0; i<grid.width*grid.height; i++) {
var cond = ((grid.getPixel(Math.floor(i%grid.width), Math.floor(i/grid.width)) == 0xFFFFFF) && (grid.getPixel(ix, iy) == 0xFFFFFF)) ? c.l.clear() : 1;
cond = cond == 1 ? 1 : c.l.lineStyle(1, 0xFFFFFF*i/(grid.width*grid.height), 40/Math.sqrt(Math.pow(Math.floor(i%grid.width)-ix, 2)+Math.pow(Math.floor(i/grid.width)-iy, 2)));
cond = cond == 1 ? 1 : c.l.moveTo(Math.floor(i%grid.width)*20, Math.floor(i/grid.width)*20);
cond = cond == 1 ? 1 : c.l.lineTo(ix*20, iy*20);
cond = cond == 1 ? 1 : bitmap.draw(c);
}
}
iy++;
if (iy>grid.height) {
clearInterval(drawInt);
}
}
function getInfo() {
var cond = Key.isDown(Key.SHIFT) ? grid.setPixel(Math.floor(_root._xmouse/20), Math.floor(_root._ymouse/20), 0xFFFFFF) : null;
cond = Key.isDown(Key.SPACE) ? "Run it!" : null;
cond == "Run it!" ? clearInterval(getInt) : "Run it!";
cond == "Run it!" ? drawInt=setInterval(drawOne, 1) : null;
}
Mouse.addListener(ml);
Enjoy ;)