See error:
sq() returns a float:
https://processing.org/reference/sq_.html
Try:
total*total which returns an int
Or this to convert the float to an int:
https://processing.org/reference/intconvert_.html
The i -- seemed to work once I corrected code but really should be i-- without spaces.
Consider this:
int t, total;
float itemSize;
void setup()
{
size(800, 800);
//pixelDensity(2);
smooth();
rectMode(CENTER);
total = 4;
t = 4;
itemSize = width/total;
}
void draw()
{
for (int i = 0; i < sq(total); i ++)
{
float x = i % total * itemSize + itemSize/2;
float y = i / total * itemSize + itemSize/2;
fill(-1);
square(x, y, itemSize * 0.8);
textAlign(CENTER, CENTER);
textSize(24);
fill(0);
text((i/t)%2, x, y-60);
text(i%t, x, y-30);
text(i, x, y);
text(i/t, x, y+30);
text(t-i%t, x, y+60);
}
}
Output from above:
From the above I was able to do some math and achieve this:
An if\else statement was used to determine odd\even lines and print the correct order.
I took advantage of integer math in my example above.
:)


