Skip to content

Enhance collage generating #31

@programmerr47

Description

@programmerr47

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions