# cotis-pipes
`cotis-pipes` is the layout-to-renderer pipe for [Cotis](https://docs.rs/cotis). It implements [`LayoutRenderPipe`](https://docs.rs/cotis/latest/cotis/pipes/trait.LayoutRenderPipe.html) — the conversion layer between [`cotis-layout`](https://docs.rs/cotis-layout) output and [`cotis-defaults`](https://docs.rs/cotis-defaults) render commands.
> **Status:** Early `0.1.0-alpha` release. APIs are still evolving alongside the core Cotis crates.
This repository contains the **pipe** only. It does not open a window or draw pixels by itself. For a runnable desktop app, combine it with core Cotis crates, a layout manager, and a renderer backend from the [ecosystem](#ecosystem) below.
## Architecture
Each frame flows through five stages. This crate owns the pipe stage:
```mermaid
flowchart LR
UI[UI_closure] --> LayoutMgr[CotisLayoutManager]
LayoutMgr --> LayoutOut[RenderCommandOutput]
LayoutOut --> Pipe[cotis-pipes]
Pipe --> Renderer[CotisRenderer]
```
1. A layout manager prepares for the frame.
2. UI code builds the element tree through the configurator API.
3. The layout manager produces layout output items (`RenderCommandOutput`).
4. **This crate** transforms those items into renderer commands (`RenderTList<…>`).
5. A renderer draws the command stream.
When layout output already matches what the renderer expects, pass `()` as the identity pipe instead (see [`CotisApp::new`](https://docs.rs/cotis/latest/cotis/cotis_app/struct.CotisApp.html#method.new)).
## Installation
Add the pipe and required core crates to your `Cargo.toml`:
```toml
cotis-pipes = "0.1.0-alpha"
cotis = "0.1.0-alpha"
cotis-defaults = "0.1.0-alpha"
cotis-layout = "0.1.0-alpha"
cotis-utils = "0.1.0-alpha"
```
A full desktop application also needs a renderer. See [Quick start](#quick-start) and [Ecosystem](#ecosystem).
## Quick start
Clone a renderer backend and run its example:
```bash
git clone https://github.com/igna-778/cotis-wgpu
cd cotis-wgpu
cargo run --example basic_example -p cotis-wgpu
```
That example opens a resizable window, lays out UI with `cotis-layout` and `cotis-pipes`, and renders through wgpu.
### Typical app wiring
```rust
use cotis::cotis_app::CotisApp;
use cotis_layout::preamble::CotisLayoutManager;
use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
use cotis_utils::math::Dimensions;
use cotis_wgpu::prelude::*;
let renderer = CotisWgpuRenderer::auto_start();
let manager = CotisLayoutManager::new(Dimensions::new(1000.0, 800.0));
let mut app = CotisApp::new(renderer, manager, CotisLayoutToRenderListPipeForGenerics);
while !app.render().window_should_close() {
app.compute_frame(|root| {
// Build your UI tree here.
});
}
```
Swap `cotis-wgpu` for [`cotis-raylib`](https://github.com/igna-778/cotis-raylib) or another backend without changing layout or UI code.
### Extending with custom drawables
Append your type to the tail of a `RenderTList` and implement [`FromRenderCommandOutput`](https://docs.rs/cotis-pipes/latest/cotis_pipes/cotis_layout_pipes/trait.FromRenderCommandOutput.html). Return `Some(cmd)` to emit a draw command or `None` to skip.
See [`cotis-layout` examples](https://github.com/igna-778/cotis-layout/tree/main/examples) — especially `support.rs` for a complete `StandardRenderCmds` alias and `circle_example.rs` for extending the pipeline with custom drawables.
## Ecosystem
Cotis is split across several repositories. This repo provides the layout-to-render pipe; sibling repos provide core traits, layout, and render backends.
| [`cotis`](https://github.com/igna-778/cotis) | Core traits and `CotisApp` orchestration |
| [`cotis-layout`](https://github.com/igna-778/cotis-layout) | Flexbox-style layout engine (`CotisLayoutManager`) |
| [**cotis-pipes**](https://github.com/igna-778/cotis-pipes) (this repo) | Layout output to render commands (`CotisLayoutToRenderListPipeForGenerics`) |
| [`cotis-wgpu`](https://github.com/igna-778/cotis-wgpu) | Desktop renderer (wgpu + winit + glyphon) |
| [`cotis-raylib`](https://github.com/igna-778/cotis-raylib) | Desktop renderer (raylib) |
| [`cotis-renderer-template`](https://github.com/igna-778/cotis-renderer-template) | Scaffold for authoring a custom render backend |
| [`cotis-cli`](https://github.com/igna-778/cotis-cli) | Plugin host for installable build and run routines |
Pick a renderer backend and swap it without changing layout or UI code. Use `cotis-renderer-template` to implement a new backend.
## Documentation
- API reference: `cargo doc --open`
- Published docs: [cotis-pipes](https://docs.rs/cotis-pipes)
- Core crate docs: [cotis](https://docs.rs/cotis), [cotis-layout](https://docs.rs/cotis-layout), [cotis-defaults](https://docs.rs/cotis-defaults), [cotis-utils](https://docs.rs/cotis-utils)