kontrol
Junior Member
Offline
Posts: 92
Re: arrayindexoutofbounds PLEASE help
Reply #2 - Sep 5th , 2007, 11:40pm
import maxlink.*; import processing.opengl.*; import pitaru.sonia_v2_9.*; PImage pixel; PImage[] myImages; int currentImage = 1; MaxLink link = new MaxLink(this, "beat_detection"); void setup() { pixel = loadImage( "gun.gif"); Sonia.start(this); LiveInput.start(128); size(800, 471, OPENGL); myImages = new PImage[2]; // load images myImages[0] = loadImage( "pibe.gif" ); myImages[1] = loadImage( "gun.gif" ); link.declareMaxFunction("beatimage"); colorMode(RGB,255,255,255,100); frame.setLocation(100,screen.height/8); } public void beatimage() { currentImage++; currentImage %= myImages.length; } void draw(){ hello(); } void hello() { float input = LiveInput.getLevel()*height*2; int cellsize = int(input); int COLS, ROWS; if(cellsize < 13){ cellsize = int(random(13,15)); } frameRate(80); COLS = myImages[currentImage].width/cellsize; ROWS = myImages[currentImage].height/cellsize; loadPixels(); imageMode(CORNER); background(0); for ( int i = 0; i < COLS;i++) { for ( int j = 0; j < ROWS;j++) { int x = i*cellsize + cellsize/2; int y = j*cellsize + cellsize/2; int loc = x + y*myImages[currentImage].width; // THIS IS THE LINE WHICH IS MARKED WHEN IT CHRASHES float z = 5* brightness(myImages[currentImage].pixels[loc]) - 100.0f; // THIS IS THE LINE WHICH IS MARKED WHEN IT CHRASHES pushMatrix(); translate(x,y,z); fill(int(random(0,255)),int(random(0,255)),int(random(0,255)),100); rectMode(CENTER); // shape beginShape(); vertex(0, 15); vertex(30, 15); vertex(30, 25); vertex(0, 25); endShape(); smooth(); noStroke(); beginShape(); vertex(10, 0); vertex(20, 0); vertex(20, 60); vertex(10, 60); endShape(); popMatrix(); } } } public void init() { frame.setUndecorated(true); super.init(); } public void stop(){ Sonia.stop(); super.stop(); }