Giter VIP home page Giter VIP logo

kiwi.js's Introduction

kiwi.js

view on npm Build Status codecov

Kiwi.js is a fast TypeScript implementation of the Cassowary constraint solving algorithm, based on the seminal Cassowary paper. Originally created by Chris Colbert, it was redesigned from the ground up to be lightweight, fast and easy to maintain. View the benchmarks to see how it compares to Cassowary.js.

Index

Getting started

Install using NPM:

npm install kiwi.js

The following example creates a solver which automatically calculates the width:

import kiwi from 'kiwi.js';

// Create a solver
var solver = new kiwi.Solver();

// Create edit variables
var left = new kiwi.Variable();
var width = new kiwi.Variable();
solver.addEditVariable(left, kiwi.Strength.strong);
solver.addEditVariable(width, kiwi.Strength.strong);
solver.suggestValue(left, 100);
solver.suggestValue(width, 400);

// Create and add a constraint
var right = new kiwi.Variable();
solver.addConstraint(new kiwi.Constraint(new kiwi.Expression([-1, right], left, width), kiwi.Operator.Eq));

// Solve the constraints
solver.updateVariables();
assert(right, 500);

Documentation

Benchmarks

To run the benchmark in the browser, just visit this page.

To run the benchmark locally using nodejs, clone or download this repository and execute the following steps:

npm install
npm run bench

Tests

To run the tests in the browser, just visit this page.

To run the tests locally using nodejs, clone or download this repository and execute the following steps:

npm install
npm run build && npm run test

Contribute

If you like this project and want to support it, show some love and give it a star.

kiwi.js's People

Contributors

sccolbert avatar ijzerenhein avatar adamhaile avatar jwiggins avatar henrikh avatar cacaodev avatar orentrutner avatar

Watchers

James Cloos avatar Sergey 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.