Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance collage generating #31

Open
programmerr47 opened this issue Jan 12, 2020 · 0 comments
Open

Enhance collage generating #31

programmerr47 opened this issue Jan 12, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@programmerr47
Copy link
Owner

programmerr47 commented Jan 12, 2020

So currently I've invented in my had a small algorithm to split rectangle on a list of random rectangles. At first I had in mind simple one (which is still a backup plan):

Split rectangle on two with either vertical or horizontal line.
Continue that for both subrectangles.
Continue 1. and 2. until some point of time
But I don't like the limitation of rectangle splitting. Because is too clumsy. It looks like you hack each rectandles on two parts every time. Which is too obvious.

So my algorithm is next:

Pick a pixel in the edge of rectangle
Start drawing line from it, perpenicular to the starting edge.
Proceed to the other edge on stop between them
If you stopped in the middle, start emit two line in one of sides (left, right, top, bottom) except the side of original line.
For each line continue either to the edge or already draw line; or stop in the middle
Continue 4 and 5, until the is no "middle" lines left
With this algorithm it is possible to draw something like:

 _________
|  |______| 
|__|___|  |
|______|__| 

Which is not possible with first algorithm. Moreover second one extend the first one in terms of number of possibilities

@programmerr47 programmerr47 added the enhancement New feature or request label Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant