I need to split a rectangle (A CGRect structure which is {{float x,float y},{float w,float h}}
) into a number of smaller rectangles/structures, creating some sort of a grid. I'm writing a window layout manager and I want a window preview option.
I saw similar questions but none of the algorithms I saw (the ones involving ceil
and floor
) worked. I've also tried:
float widthOfNewRect = total.size.width / floor(sqrt(n));
float heightOfNewRect = total.size.height / ceil(sqrt(n));
Can someone provide an example of doing it with my structure in C?