tiling algorithm
category: code [glöplog]
Does anyone know of a good algorithm to tile squares together?
how do you mean?
an algorithm to pack various size squares as tight as possible
The thing you should look out for is called packing problems in mathematics (not tiling). There are many different packing problems based on different geometric shapes.
Maybe this code and algorithm description is helpful to you: https://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu
Maybe this code and algorithm description is helpful to you: https://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu
What you're looking for is called 2d bin/rect packing, commonly used algorithms are the "shelf" algorithm and the "guillotine" algorithm, however (speaking for textures) things become quite tricky once interpolation, filtering, wrapping and god forbid mip mapping come into play.
Perhaps Smart2DCutting ?
Squares or rectangles?
my bad, rectangles
That Blackpawn article is an old classic, which I can also recommend having used it myself with good results.
Or if you can't be arsed: https://github.com/nothings/stb/blob/master/stb_rect_pack.h
Thanks everyone!!!!!!!!!!