Git Product home page Git Product logo

maximal-rectangle's Introduction

Maximal Rectangle

About

It is a Delphi implementation of the maximal empty rectangle problem3. Interest was sparked by an article by David Vandevoorde,The Maximal Rectangle Problem1. The idea of the algorithm for solving the problem is based on a paper by Thomas M. Breuel, Two Geometric Algorithms for Layout Analysis2.

Note: The accompanied example app will avoid enumerating Windows Store based apps because of the lack of cloaked window detection. That requires further usage of DwmAPI, and more code to be written. That is outside the scope and intentions of the example code provided.

API

Constructor

TMaximalRectangle.Create(bound);

Names Required Type Description
bound false TRect bounding rectangle

Properties

Names Description
Count count of added obstacles
Obstacles returns an array of added obstacles

Methods

Names Description
SetBound() sets bounding rectangle
AddObstacle() adds an obstacle
ClearObstacles() clears all added obstacles
GetMaxWhitespace() returns a computed TRect of maximal empty rectangle space

Usage

procedure TfrmMain.DoFindMaximalWhiteSpace;
var
  BoundingRect : TRect;
  MaximalRect : TRect;
begin
  BoundingRect := Rect(0, 0, 1024, 512);
  Maximal := TMaximalRectangle.Create(BoundingRect);
  try
    Maximal.ClearObstacles;

    Maximal.AddObstacle(Rect(0, 0, 100, 100));

    if Maximal.GetMaxWhitespace(MaximalRect) then begin
      Self.BoundsRect := MaximalRect;
    end;
  finally
    Maximal.Free;
  end;
end;

References

  1. David Vandevoorde, "The Maximal Rectangle Problem", Dr Dobb's, 1998.

  2. Thomas M. Breuel, "Two Geometric Algorithms for Layout Analysis", Xerox Palo Alto Research Center, 2002.

  3. "Largest empty rectangle", In Wikipedia. Retrieved February, 2017.

License

Maximal Rectangle is released under the MIT license. See LICENSE for details.

maximal-rectangle's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.