PDA

View Full Version : [Smily Entry 2] - NodeDraw 2



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 ;)

kdd
January 28th, 2006, 09:30 PM
that's great! :thumb:

Jeff Wheeler
January 28th, 2006, 09:45 PM
I don't see anything… :(

JoshuaJonah
January 28th, 2006, 09:46 PM
lol.... read the instructions

Jeff Wheeler
January 28th, 2006, 09:48 PM
Err… it still doesn't work.

ElectricGrandpa
January 29th, 2006, 02:35 AM
Why is it so slow? Lol...

For those who it's not working for, hold shift, draw some lines, then press space... then wait like 30 seconds... haha

Jeff Wheeler
January 29th, 2006, 03:19 AM
Ha. It works fine on this machine. I was on my dad's notebook earlier.

hybrid101
January 29th, 2006, 05:39 AM
ery intensive, but the effect is super sweet!!! i love this entry! but the drawing came out after, like, 10 seconds...

Smily
January 29th, 2006, 06:14 AM
Thanks for comments! The slow speed is partly because of compressed code and partly because it loops through all-the-pixels^2 because it has to compare each white pixel with each other white pixel. :)