Skip to content

Instantly share code, notes, and snippets.

@cacaodev
Last active May 23, 2017 18:31
Show Gist options
  • Save cacaodev/b2a27349c84601e9fd0d559fdaa2d589 to your computer and use it in GitHub Desktop.
Save cacaodev/b2a27349c84601e9fd0d559fdaa2d589 to your computer and use it in GitHub Desktop.
kiwi Strength bug
var priority = function(p)
{
return kiwi.Strength.create(0, 1, 0, p);
};
var kiwi = require("kiwi.js")
var solver = new kiwi.Solver();
var width = new kiwi.Variable("width");
var widthExp = new kiwi.Expression(width);
var antiCompression = new kiwi.Constraint(widthExp, kiwi.Operator.Ge, 100, priority(510));
var holding = new kiwi.Constraint(widthExp, kiwi.Operator.Eq, 50, priority(10));
solver.addConstraint(antiCompression);
solver.addConstraint(holding);
solver.addEditVariable(width, priority(501));
solver.suggestValue(width, 90);
solver.updateVariables();
width.value();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment