 |
Author |
Topic: Work Goddamn you! (array object with boolean guts) (Read 254 times) |
|
st33d

|
Work Goddamn you! (array object with boolean guts)
« on: Oct 23rd, 2004, 12:52am » |
|
It's late. I'm sorry to ask this piffle question but after a week of Bresenham madness (which may have been caused by a bug in the AIExport library - I had a chat with the guy, it's been fixed but there's still a bug with Processing's 3D line drawing accuracy. The AIExport was using the 3D line model but has been changed to the 2D one and is pixel perfect now for folks to download. Yay export guy) my brain is kaput. Code: dstore[] pix = new dstore[pixels.length]; void setup(){ for (int ip=0;ip<pixels.length;ip++){ pix[ip] = new dstore(false); } } void draw(){print("happy");} class dstore{ boolean [] d=new boolean [8]; dstore (boolean dt){ for (int id=0;id<8;id++){ d[id]=dt; } }//dstore; }//class; |
| I'm writing an ultra slim model of the Bresenham scanner (8 directions instead of all directions). It works but overwrites lines when it scans. That means ludicrous file sizes (The Bresen scanner made a 7 meg file for a 10 by 10 square of pixels, that's permutations for you). So I've written an object array that will sit on top of every pixel on screen and stop the line writer from carving a new line when it encounters a true switch for that direction. I've never written an object array before. It's giving me an out of memory error. Why doesn't it like me?
|
I could murder a pint.
|
|
|
st33d

|
Re: Work Goddamn you! (array object with boolean g
« Reply #1 on: Oct 23rd, 2004, 2:51pm » |
|
Nevermind. Tested the code with out using pixels.length and it worked fine. I thought I might be using too much memory but then I guessed that the pixels[] array may not have been initialised before the setup. So I resolved it this way: Code: int a=100; int b=100; dstore[] pix = new dstore[a*b]; void setup(){ size(a,b); for (int ip=0;ip<(a*b);ip++){ pix[ip] = new dstore(); } } void draw(){print("happy");print(pix[5683].d[4]);} class dstore{ boolean [] d=new boolean [8]; dstore (){ for (int id=0;id<8;id++){ d[id]=false; } }//dstore; }//class; |
| Lesson to you all, dont ask for pixels[] too early (...in the morning).
|
I could murder a pint.
|
|
|
|