put x-y coordinates into 2d array
in
Programming Questions
•
6 months ago
hello, it should be simple:
I draw a 10x10 grid, and each center of the rects that are created.
I would like to put x-y coordinates of each center point into an array in order to make some drawing stuffs with them. (like drawing lines between each center and the mouse cursor, or define the distance between centers and mousecursor).
here's my code:
I draw a 10x10 grid, and each center of the rects that are created.
I would like to put x-y coordinates of each center point into an array in order to make some drawing stuffs with them. (like drawing lines between each center and the mouse cursor, or define the distance between centers and mousecursor).
here's my code:
- void setup()
{
size(800, 800);
for (int i =0; i<10; i++)
{
line(i*width/10, 0, i*width/10, height);
line(0, i*height/10, width, i*height/10);
}
for (int k= 0; k<10;k++)
{
for (int l=0; l<10; l++)
{
fill(random(255), random(255), random(255));
ellipse(width/20+k*width/10, height/20+l*height/10, 10, 10);
}
}
}
void draw()
{
}
thanks in advance
1