# Int to Grid (vec2)?

Hi everyone,
a beginner to vvvv here.

I have a specific number of items (10 for example) I would like to distribute them in a grid automatically.
Is there an object that does that? I can’t find any.

Thanks!
Sergio

GridSpread produces a 2D grid as output so it takes a 2D count as input.
This way you can control if your grid is square or wider in some direction.

Question to you is what output do you expect for a grid of 10 items?
How many rows x how many columns?
Should one ‘final’ row or column be partially filled?

You’re right, I didn’t explained properly.
I would like my grid to be te closest possible to a square.
For example if the Count parameter is:

• 4 = 2x2
• 6 = 3x2
• 10 = 5x2
I already know there will be problems with prime numbers.

Yeah I guess a solution to distribute 10 elements in a grid could be 3 rows with 3 columns and a final row with only 1 value:

• [0] [1] [2]
• [0] [1] [2]
• [0] [1] [2]
• [0] [-] [-]

Since I posted this in the forum I have no idea what to do, so I’m just asking what would you do if you had to display a Grid but you only have an Int for “Count” and not a Vec2(Int).

Thanks!

Ok.

. I’m not at the laptop now but off the top of my head:

Simple way is just specify a row or column size.

So use a Int2(Create) node and put count/RowSize in X and RowSize n Y.
(So 10/2 in X and 2 in Y)

I can post a more general square solution a bit later

And here’s a solution for getting square ish results

1 Like

@tobyk Woa that’s great, thank you so much!
This works just perfect!
(note that if not in Round mode “Count” like 13 or 14 will result in a 3x4 grid, but with the Round mode on it is just perfect.)

Good catch! I missed that.
For completeness sake here’s an update with that issue fixed.