exporting text file gives messed up results

i want to export a text file with 0's and 1's but the file i get is missed up, it looks like it misses a row row or something but when i count they are all there... i hope some of you can help me

int pixelCount = 64;
int xpos = 0;
int ypos = 0;
float [] pixelSize = new float[pixelCount];
int [] drawnPixel = new int[pixelCount];
float [] xPos = new float[pixelCount];
float [] yPos = new float[pixelCount];
PrintWriter output;


void setup() {
  size(400, 450);  // size always goes first!
  output = createWriter("image.txt");
  if (frame != null) {
    frame.setResizable(false);
  }

  for (int i=0; i<pixelCount; i++) {
   pixelSize[i] = 50;
   xPos[i] = xpos+25;
   xpos += 50;
   yPos[i] = ypos+25;
   if(xpos == 400) {
    xpos = 0;
   ypos += 50;
   }

  }
}

void draw() {
 background(255);
for(int i=0; i<pixelCount; i++){
smooth();
fill(255,255,255,255);
//noStroke();
ellipse(xPos[i],yPos[i],50,50);
if(drawnPixel[i] == 1) {
      fill(255,0,0,255);
      ellipse(xPos[i],yPos[i],50,50);
}

for(int z = 0; z < 64; z++) {
  if(mouseX > xPos[z]-25 && mouseX < xPos[z]+50-25) {
    if (mouseY > yPos[z]-25 && mouseY < yPos[z]+50-25){
    if (mousePressed && (mouseButton == LEFT)) {
      drawnPixel[z] = 1;
    } else if (mousePressed && (mouseButton == RIGHT)) {
     drawnPixel[z] = 0; 
    }

  //} 

}

}
}
}

if(mouseY > 400 && mousePressed) {
  for(int z = 0; z < 64; z++) {
  output.print(drawnPixel[z]);
  if(z == 6) {
   output.println(drawnPixel[z]); 
  } else if(z == 14) {
       output.println(drawnPixel[z]); 
  } else if(z == 22) {
       output.println(drawnPixel[z]); 
  } else if(z == 30) {
       output.println(drawnPixel[z]); 
  } else if(z == 38) {
       output.println(drawnPixel[z]); 
  } else if(z == 46) {
       output.println(drawnPixel[z]); 
  } else if(z == 54) {
       output.println(drawnPixel[z]); 

}
  }
  output.flush(); // Writes the remaining data to the file
  output.close(); // Finishes the file
}





}
Tagged:

Answers

  • "it looks like it misses a row row or something but when i count they are all there"
    So is it missing or is it here? What result do you expect and what do you get?

Sign In or Register to comment.