simple sineWave example - ArrayIndexoutofbounds
              in 
             Programming Questions 
              •  
              6 months ago    
            
 
           
             Dear folks - i am playing with sineWave examples but this simple test-example does not work (2.0b8) in the marked row causing ArrayIndexoutofbounds.... cannot find out WHY.  thx for any help _ pricessin
            
            
             float[] sineWave = new float[width]; // initialize sineWave ARRAY
            
            
             void setup () {
            
            
             size (200,200);
            
            
             // ASSIGN: FILL the ARRAY with values from sin ():
            
            
             for (int i = 0; i < width; i++) {
            
            
             float r = map(i, 0 , width, 0, TWO_PI);
            
            
             sineWave[i] = abs(sin(r));
            
            
             }}
            
            
             void draw () {
            
            
             background (0);
            
            
             // SET the stroke value to the numbers of the array
            
            
             for (int i=0; i<sineWave.length; i++) {
            
            
             stroke(sineWave[i] * 255);
            
            
             line (i,0,i,height);
            
            
             }}
            
             
              
              1  
            
 
            
 
 
           
 
             
              
              
 
             
              
             