autolayout.wasm

fast AutoLayout & VFL for the Web. Written in C++, compiled to WASM using Emscripten.


License
ISC
Install
npm install autolayout.wasm@0.1.1

Documentation

npm

autolayout.wasm

This library is inspired by autolayout.js, but is several times faster.

install

npm i -S autolayout.wasm

basic usage

import AutoLayout from "autolayout.wasm";

//we need to wait the .wasm file loaded
AutoLayout.ready.then(()=>
{
    let view =  new AutoLayout.View();
    let cons = AutoLayout.parse_evfl(`
        H:|-[a(123)]-[b(456)]-| |~[c)]~|; 
        V:|[a][b]|; 
        C:d.w(50%).h(100).cx(0).cy(0)`
    );
    view.raw_addConstraints(cons, false);
    
    view.update();
    
    let subViews = {};
    view.getSubViews(subViews);
    
    for(let name in subViews)
    {
        let sv = subViews[name];
        console.log(`${name}: ${sv.left()}, ${sv.top()}, ${sv.width()}, ${sv.height()}`);
    }
});
	

build

  • make sure these are installed:
  • set these environment variables:
    • EMSCRIPTEN_CMAKE_TOOLCHAIN_FILE (eg. /Developer/emsdk/emscripten/1.38.30/cmake/Modules/Platform/Emscripten.cmake)
    • BOOST_ROOT (eg. /usr/local/Cellar/boost/1.69.0)
  • run npm test

todo: documentation