Looking for a Library to Handle Nesting Rectangles Recursively

0
13
Asked By DynamicDoodle42 On

Hey everyone! I'm searching for some libraries or packages that manage rectangles that can contain other rectangles, and this nesting can go pretty deep. Here's what I'm hoping to find:

1. Each rectangle can have multiple child rectangles, and those children can even have their own child rectangles.

2. The positioning of child rectangles is based on the lower left corner of their parent. For instance, if Rectangle A contains Rectangle B positioned at [1, 1] and Rectangle A is drawn at [2, 2] on the canvas, then Rectangle B should appear at [3, 3] on the canvas.

3. Each rectangle (including children) should have a rotation attribute allowing for 0, 90, 180, or 270 degrees. So, if Rectangle B rotates 90 degrees, it should position itself accordingly at [1, 1] within Rectangle A.

4. All placements and rotations need to happen recursively, meaning if Rectangle B is rotated, all of its children should rotate with it.

I've checked out shapely, but it doesn't really handle child rectangles well at all. Any suggestions for libraries that can accommodate these needs?

2 Answers

Answered By SketchySolutions On

Have you considered what your main goal is with this? Both manim and Kivy can support such functionality, but they're more feature-packed than just geometric libraries. If all you need is rectangle handling, rolling your own solution could be wise.

DynamicDoodle42 -

Thanks for the suggestions! I just want to manage the rectangle nesting cleanly, so rolling my own might actually be a good path.

Answered By CleverCoder88 On

You might not even need a library for this! It sounds like a problem that can be solved pretty effectively using matrix multiplication along with recursion for the hierarchy. Just a thought!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.