bpartridge / autoblocks.js

Easy, automatic layout for constrained graphs of HTML elements

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autoblocks.js

Autoblocks.js makes it easy to create dynamic graphs or trees of HTML elements that magically rearrange themselves on the fly as new elements are added, dimensions are changed, or relationships are added. These relationships can be trivially specified by adding classes to elements, or by linking Autoblocks.js to a Backbone.js collection whose model attributes specify parent-child relationships. This library can be run in Node.js or in any reasonably performant browser (Chrome and Firefox tested).

Autoblocks.js is licensed under the LGPL v2.1, so it can be used alongside proprietary (obfuscated) Javascript code. However, any published modifications to this library itself, or its components, must be released under the LGPL or GPL v2 or v3.

Implementation

Autoblocks.js accomplishes this with the first-ever Javascript implementation of a linear program optimizer, which optimizes a simple objective function subject to a set of constraints. HTML elements or Backbone models are translated into these constraints by customizable "Binders" and "Constrainers", and the solution of the linear program updates the locations in a deterministic way.

The specific algorithm implemented in src/lp.js is the parametric self-dual simplex method presented in Chapter 7 of Robert J. Vanderbei's Linear Programming: Foundations and Extensions, which can be downloaded at an archived version of the author's website. Note that this implementation did not use the source code provided on Prof. Vanderbei's website as a reference, as its licensing requirements are unclear. Autoblocks makes use of the Sylvester linear algebra library.

Note that much of the source code is written in CoffeeScript.

Testing

Jasmine is used for testing.

In the main directory:

node node_modules/jasmine-node/lib/jasmine-node/cli.js --runWithRequireJs --verbose .

About

Easy, automatic layout for constrained graphs of HTML elements

License:GNU Lesser General Public License v2.1


Languages

Language:JavaScript 87.4%Language:CoffeeScript 12.3%Language:Shell 0.3%