Home > database >  How can i fill a square with randomly sized squares and rectangles
How can i fill a square with randomly sized squares and rectangles

Time:05-31

So i need to know how i can go about filling an area with randomly sized rectangles and squares - like this for instance:

I already have a partially working demo however it has alot of instances in where it will not work and ontop of this it requires alot of manual checks which isn't the easiest thing to program nor is it efficient.

Ontop of the challenge at hand i'd like to also avoid using methods that require checking collision such as using an attached RigidBody2D or a Ray cast as i'm working with ui and would like to simply generate a table of locations and sizes for easier access (however if this is unavoidable i understand and please do still share your answer if this is the case)

I was hoping to simulate it in the sense of a table where you can merge cells together but i'm uncertain how this is achievable - if at all.

Thankyou in advance! :)

Edit:

In relation to UnholySheep's comment i found enter image description here

Example Result 6x6:

enter image description here

CodePudding user response:

This is what you want to do - i may upload the source code to github and link it here if i get round to it

  • Related