Setup loops endlessly
in
Programming Questions
•
1 year ago
As it is, the println in the second loop just starts back from 0 over and over and I cannot figure out why. If I remove everything but the println in the second loop it does move onto the draw function. Any possible reasons?
- void setup() {
- size(400, 500, P2D);
- background(255,0,0);
- frameRate(25);
- noStroke();
- frameNumber = 0;
- robDrawing = loadImage("drawing.png");
- robDrawing.loadPixels();
- // Scan loaded image first and grab all pixels that aren't black.
- // Grab their coords and their colours.
- for (int x = 0; x < robDrawing.width; x++) {
- for (int y = 0; y < robDrawing.height; y++) {
- if (robDrawing.pixels[(y * robDrawing.width) + x] != color(0)) {
- PVector newEndPoint = new PVector(x+ 50,y,0); // + 50 centres it
- scanEnd = (PVector[])append(scanEnd, newEndPoint);
- scanColor = (color[])append(scanColor, color(robDrawing.pixels[(y * robDrawing.width) + x]));
- }
- }
- }
- int totalDrawingPixels = scanEnd.length;
- // Now from the windows width to height, assign a start, end and colour to every pixel
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- PVector newStartPoint = new PVector(x,y);
- crayonStart = (PVector[])append(crayonStart, newStartPoint);
- int convertRef = ((y * width) + x)%totalDrawingPixels;
- crayonEnd = (PVector[])append(crayonEnd, scanEnd[convertRef]);
- crayonColor = (color[])append(crayonColor, scanColor[convertRef]);
- journeyRatio = (float[])append(journeyRatio, 0.5);
- println(((y * width) + x) + " / " + (width * height));
- }
- }
- }
1