demidelirium
YaBB Newbies
Offline
Posts: 4
outofboundsexception lesson 101
Mar 1st , 2006, 12:38am
hi, apologies if this gets covered every time a newbie runs into it, i did search the board first tho... i made an amended version of the pixelarray example sketch, had an idea for some pdf vector stuff i wanted to try, and this first experiment works quite nicely, for a short time, then it grinds to a halt: java.lang.ArrayIndexOutOfBoundsException: 40001 at Temporary_5229_6325.draw(Temporary_5229_6325.java:27) at processing.core.PApplet.display(PApplet.java:1326) at processing.core.PGraphics.requestDisplay(PGraphics.java:520) at processing.core.PApplet.run(PApplet.java:1142) at java.lang.Thread.run(Unknown Source) you can see it at http://www.demiology.com/p5/pixelArrayModified just click and drag horizontally to create straight line patterns, akin to the old 1-pixel wide full height selection in photoshop being transformed for instant patterns... the code: import processing.pdf.*; PImage a; color cp; int[] aPixels; void setup() { size(200, 200); noFill(); noStroke(); framerate(30); a = loadImage("updoc.jpg"); aPixels = new int[width*height]; for(int i=0; i<width*height; i++) { aPixels[i] = a.pixels[i]; } } void draw() { background(51); image(a,0,0); if(mousePressed) { //beginRecord(PDF, "frame-####.pdf"); for (int i=0; i<height; i++) { cp = aPixels[i*width + mouseX]; stroke(cp); line(0,i,width,i); } //endRecord(); } } thanks if you can tell me what it is i should be doing here! d