An open API service indexing awesome lists of open source software.

https://github.com/skyleite/luyoga

Lua bindings to facebook/yoga
https://github.com/skyleite/luyoga

css layout-engine love2d lua ui yoga

Last synced: 6 months ago
JSON representation

Lua bindings to facebook/yoga

Awesome Lists containing this project

README

          

# Luyoga

This is a set of Lua-friendly bindings for [Yoga](https://www.yogalayout.dev), Facebook's layout library.

## Setup

Simply copy the `luyoga` directory to your project and require it.

## Usage

The library is designed to resemble Yoga as closely as possible, so the official docs should be enough to learn how to use it.

### Building a Yoga tree

```lua
local yoga = require("yoga")

local root = yoga.Node.new()
root.style:setFlexDirection(yoga.Enums.FlexDirection.Row)
root.style:setWidth(100)
root.style:setHeight(100)

local child0 = yoga.Node.new()
child0.style:setFlexGrow(1)
child0.style:setMargin(1, yoga.Enums.Edge.Right)
root:insertChild(child0, 0)

local child1 = yoga.Node.new()
child1.style:setFlexGrow(1)
root:insertChild(child1, 1)
```

### Laying out the tree

```lua
root:caculateLayout(nil, nil, yoga.Enums.Direction.LTR)
```

### Reading layout results

```lua
local left = child0.layout:getLeft();
local height = child0.layout:getHeight();
```

## Contributing

### Running locally

1. Build the project locally using `luarocks make --tree=./dev --no-manifest luyoga-1.0-1.rockspec`
2. Update `test.lua` with your code and run it with `luajit test.lua`

### Writing tests

TODO