We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm working on a project that builds a cutsheet for laser cutting objects based on audio analysis. A delay is necessary to allow sampling different parts of the audio.
So far, I've managed to get it working through one line, but I want it to work with any amount of rows/columns
I've posted the stripped down version ofmy code, which works for drawing a simple object at pre-set coordinates along one line. For some reason, it's not working through the y position array, though.
Anyone have an idea that might make this work?
int counter=0;
int grid=10;
int[] x = new int[grid];
int[] y = new int[grid];
int savedTime;
void setup() {
size(1200, 1200);
background(0);
smooth();
//initialize grid coordinates
for (int i=0;i<grid;i++) {
x[i] = i*100;
y[i] = i*100;
}
savedTime = millis(); //save current time
}
void draw() {
println(savedTime);
int line=0; //increment to adjust y position
//iterate through coordinate arrays
for (int i = 0; i < counter; i++) {
ellipse(x[i], y[line], 50, 50);
} // for
//draw based on time delay
if (millis ()- savedTime >= 500) {
savedTime = millis();
counter++;
//increase y values when end of line is reached
if (counter>=grid){
counter=0; // edited
line++;
}
} // if
} // func
Answers
Hi you are reseting line to 0 every draw() loop in line 28 . Declare line as a global var and delete that line.
int line = 0;//here
Ah I knew it was something simple. Thanks so much!