I need help with grid creation

HI.

I need help to find an algorithm to have a center rect and then all other rects to be positioned around the center, probably all rects will need some sort of math so that their size is adjusted slightly for this as well.

I did some drawing I am having difficulty explaining this so I don’t know how to start.

I will use this grid in threejs with some shaders.

I managed to do it like this Shader Carousel but I want more randomness… In my working example all sects have the same height… this is the issue

Thank you.

That’s a hard problem if the rectangles are predefined dimensions.
I’ve done it before with d3 force directed graphs but that’s an iterative approach.

If they can be arbitrary, but you just want random… you could use some kind of space filling subdivision, seeded with your initial rectangle.

5 Likes

Thank you for your help I am still lost at this the articles help but they are not getting me closer to what I need… indeed a really difficult one.

1 Like

If you would let an algorithm pick the sizes of the rectangles, just use a room-maze generator and pick a bunch of rooms around some central room.

In the illustration below the black lines are walls of randomly generated rooms, the red circle is your bunch, the pink rooms are the selected rooms for the grid.

6 Likes

Good tip the issue is that I can’t generate them completely random they need to keep visually a close image ratio it dose not have to have the image ratio perfectly but to be as close as possible

best I could get from gpt…

@PavelBoytchev suggestion above has great potential

5 Likes

It is close I managed to do soething similar the issue is how do you make it to fit perfectly the gaps to be visually exactly the same, this will require to ‘adapt’ somehow the meeshs size as well but keeping in mind the iamge ratio… I cant even put this on paper:)

I tried to do that but failed I found a different way to create the grid but is not as cool as the one I wanted to do… darn it!

https://webdesign-flash.ro/ht/grid/

I have made a different version, unfortunately I could not code what I wanted grid wise but I am happy with it

I would appreciate an opinion on performance.

Have you seen the recent Zim Texture Active exposé? Users can leverage Fabric.js underlying state engine. That means SVG grids are basically free.

I don’t think you understand what I need…

Sorry! There are 3,333 masonry libraries for flat DOM rectangles. They have gutters and columns and sort orders.

What I need is not masonry, please look at what I asked!

FWIW repeating myself won’t make my contribution more valid.

Thank you for trying to help but you don’t understand what I need!

This is my favorite version Shader Grid