As the title implies, is there a general rule that I can apply instead of using offset and padding to make a grid.

as it stands I try to make a grid using the following code

```
for (int i=0; i<sides; i++) {
float thetab = theta * i;
float thetac = theta * i+theta;
walls[i] = true;
walls2[i] = true;
wallsBackup[i] = true;
node_info.add(new Integer[3]);
edge.add(new PVector[2]);
//println("edge init", x, y);
edge.get(i)[0] = new PVector(x+w/2*sin(thetab), y+h/2*cos(thetab));
edge.get(i)[1] = new PVector(x+w/2*sin(thetac), y+h/2*cos(thetac));
vertex[i]= new PVector(x+w/2*sin(thetac), y+(h/2)*cos(thetac));
length = dist(x+w/2*sin(thetab), y+h/2*cos(thetab), x+w/2*sin(thetac), y+h/2*cos(thetac));
}
```

I have to add some extra rules to make it more palatable and even then it doesnt work for every grid all the time.

```
if (sides>4)
if (pos==1) {
x = (xpos-0.5) *g.tileWidth+w-(xpos*w/sides+xpadding)+xoffset;
} else {
x = (xpos) *g.tileWidth+w-(xpos*w/sides+xpadding)+xoffset;
} else x = (xpos) *g.tileWidth;
```

and this is the result

then when changing number of sides