A high performance & cross-platform layout engine
Written in Rust
We chose to write stretch in the Rust programming language as it ensures memory safety, efficient multi-threading, and has fantastic cross-platform support.Optimised for mobile
While stretch can be used on any platform we chose to optimize it for mobile. This means a small binary size and minimal memory usage.Tested against Chrome
Stretch is tested against Chrome to ensure 100% web compatibility. You can trust stretch to layout your native apps exactly like your web apps.Cross platform
main.rs
use stretch::{style::*, node::*, geometry::Size};
let stretch = Stretch::new();
let node = stretch.new_node(Style {
size: Size {
width: Dimension::Points(100.0),
height: Dimension::Points(100.0),
},
..Default::default()
}, vec![]).unwrap();
stretch.compute_layout(node, Size::undefined());
index.js
import { Allocator, Node } from 'stretch-layout';
const allocator = new Allocator();
const node = new Node(allocator, {
width: 100,
height: 100,
});
const layout = node.computeLayout({
width: undefined,
height: undefined,
});
Main.swift
let node = Node(
style: Style(
size: Size(
width: .points(100.0),
height: .points(100.0)
)
),
children: []
)
let layout = node.computeLayout(
thatFits: Size(width: nil, height: nil)
)
Main.kt
val node = Node(
Style(
size = Size(
Dimension.Points(100f),
Dimension.Points(100f)
)
),
listOf()
)
val layout = node.computeLayout(
Size(null, null)
)