Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Project logo

Travis Unit Test Build Status

haxe-kiwi is a port of Kiwi and Kiwi Java, implementations of the Cassowary constraint solving algorithm. Run the demo in your browser.

Visit Overconstrained and join the Slack group to find out more about constraint solvers or get involved in development.



  • Solving systems of linear constraint equations.
  • String parsing for constraint creation.
  • Edit variables.

Doesn't support:

  • Stay constraints.


haxe-kiwi depends on assertion library Sure, install that first:

haxelib install sure

Include the library through Project.xml:

<include path="lib/haxe-kiwi/include.xml" />

See the demo code, the unit tests, or run the demo in the browser for usage examples.

Screenshot of demo app

// Basic usage
var solver = new Solver();

// Constraints are written in the form: a [==|<=|>=] b [*/] c [+-] d
var problem:String = '{"inequalities":["x == 20", "x == y + 10", "z == y + 30", "q == z + x", "foo == z + x", "bar == foo + x", "baz == foo * 10", "boz == x / 10 + y / 10 + x * 5"]}';
var structure:{inequalities:Array<String>} = Json.parse(problem);

var resolver:VarResolver = new VarResolver(); // Simple map wrapper that caches variables so that duplicates aren't added to the solver
for (inequality in structure.inequalities) {
	var constraint = ConstraintParser.parseConstraint(inequality, resolver, "required");
solver.updateVariables(); // Update the values of the external solver variables

// Trace the value of external solver variable x (expect 20)
var x = resolver.resolveVariable("x");
trace("x = " + x.value);

resolver.traceVariables(); // Trace all the variables captured by the resolver


  • There is a unit test repository for the library here.
  • All Haxe targets are supported.


  • haxe-kiwi is a port of the Kiwi UI constraint solver v0.1.3. Kiwi was written by Chris Colbert, lead of the Nucleic Development Team. Their core team that coordinates development on GitHub can be found here:
  • Parts of this port were adapted from Kiwi.js, a JavaScript port of Kiwi, which is also written by the Nucleic Development Team.
  • String parsing code for constraints and some tests were ported from kiwi-java, a Java port of Kiwi by Alex Birkett.


🐦 Haxe port of Kiwi, an implementation of the Cassowary constraint solving algorithm





No releases published
You can’t perform that action at this time.