problem with for loop
in
Programming Questions
•
1 year ago
Hello,
I am a newbie, so I guess it will be straightforward thing that I encounter. But if someone can help me that would be great.
I have following code running:
// start
PImage b;
float sectorSize = 12;
void setup() {
size(976, 1560);
smooth();
b = loadImage("img.png");
noStroke();
}
void draw() {
for (int i = 0; i < 976; i += sectorSize ) {
// rect(i,0,sectorSize,sectorSize);
println("Sectorname =" + sectorX + "_" + sectorY);
sectorX = sectorX + 1;
}
I would expect the loop to go on for 81 sectors (81*12 should be about 976) but it keeps running endlessly.
These are the last println after I aborted the script:
Sectorname =17859_1
Sectorname =17860_1
Sectorname =17861_1
Sectorname =17862_1
Sectorname =17863_1
Sectorname =17864_1
Sectorname =17865_1
Sectorname =17866_1
Sectorname =17867_1
Sectorname =17868_1
Sectorname =17869_1
Sectorname =17870_1
Sectorname =17871_1
Sectorname =17872_1
Sectorname =17873_1
Sectorname =17874_1
Sectorname =17875_1
Sectorname =17876_1
Does anyone see where I am going wrong here?
Thanks in advance!!
1