got an NullPointerException when i try to initiate a double Array in the last Beta
in
Core Library Questions
•
11 months ago
Hi,
I created a sketch without problem on my pc with processing 1.5
since i transferred it on my mac where i use the beta 2b05 i got an error of NullPointerException when i initiate my double array levelAlpha.
I tried to create a double Array in another empty skecth and that worked, so where is my error ?
I tried to create a double Array in another empty skecth and that worked, so where is my error ?
so my code is :
- // different variable
- int largeur=368;
- int hauteur=490;
- int larg=20;
- int haut=10;
- int largCol=largeur/larg;
- int hautCol=hauteur/haut;
- int id1=0;
- int id2=0;
- // it's seem impossible to initiate this
- int[][] levelAlpha=new int[36][49];
- int d=0;
- // list of piture
- String[] liste1= {"face1.jpg", "face2.jpg", "face3.jpg"};
- String[] liste2= {"face4.jpg", "face5.jpg", "face6.jpg"};
- //if it's first
- boolean pile= true;
- // create the PGraphics for the alpha mask and the syphon output
- PGraphics masque = createGraphics(largeur, hauteur, P2D);
- PGraphics sortie = createGraphics(largeur, hauteur , P3D);
- PImage image1;
- PImage image2;
- void setup() {
- size(360, hauteur);
- frameRate(30);
- // initiate the doubleArray
- for (int i=0;i<largCol-1;i++) {
- for (int j=1;j<hautCol-1;j++) {
- levelAlpha[i][j]=0;
- }
- }
- //load the first images
- image1=loadImage(liste1[id1]);
- image2=loadImage(liste2[id2]);
- }
- void draw() {
- background(127);
- // create the alphaMask
- masque.beginDraw();
- masque.noStroke();
- for (int i=0;i<largCol;i++) {
- for (int j=0;j<hautCol;j++) {
- if (i<d&&j<d) {
- if (pile/*&&levelAlpha[i][j]<255*/) {
- levelAlpha[i][j]+=20;
- }
- else if (/*levelAlpha[i][j]>0&&*/!pile) {
- levelAlpha[i][j]-=20;
- }
- }
- if (levelAlpha[i][j]>255)
- {
- levelAlpha[i][j]=255;
- }
- if (levelAlpha[i][j]<0) {
- levelAlpha[i][j]=0;
- }
- masque.fill( levelAlpha[i][j]);
- masque.rect(i*larg, j*haut, larg, haut);
- }
- }
- masque.endDraw();
- // apply the mask to the first picture
- image1.mask(masque.pixels);
- // create the syphon output
- sortie.beginDraw();
- sortie.image(image2, 0, 0);
- sortie.image(image1, 0, 0);
- sortie.endDraw();
- image(sortie,0,0);
- d++;
- //define if one of the pass is ended and which one must happen then
- if (levelAlpha[largCol-1][hautCol-1]==255&&pile) {
- d=0;
- pile=false;
- id1++;
- if (id1>liste1.length-1)id1=0;
- image2=loadImage(liste1[id1]);
- }
- else if (levelAlpha[largCol-1][hautCol-1]==0&&!pile) {
- d=0;
- pile=true;
- id2++;
- if (id2>liste2.length-1)id2=0;
- image1=loadImage(liste2[id2]);
- }
- }
1